Skip to content

Commit

Permalink
build(package): ✨ Update package structure according to R CMD CHECK r…
Browse files Browse the repository at this point in the history
…esutls.

Helps to prepare the package for possible publication in the future.
  • Loading branch information
effendiian committed Dec 7, 2023
1 parent 0256062 commit 849b2c2
Show file tree
Hide file tree
Showing 17 changed files with 2,196 additions and 2 deletions.
13 changes: 13 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,16 @@
^LICENSE\.md$
^README\.Rmd$
^cran-comments\.md$
^venv$
^bin$
^\.python-version$
^\.github$
^\.vscode$
^\.pre-commit-config.yaml$
^rcmdcheck.log$
^\.lintr$
^(inst/)?CITATION(.cff)?$
^_targets(.R)?$
^CHANGELOG.md$
^LICENSE-DOCS$
^requirements.in$
1 change: 1 addition & 0 deletions .Rprofile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
source("renv/activate.R")
4 changes: 4 additions & 0 deletions .lintr
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
linters: linters_with_defaults(
indentation_linter = indentation_linter(4)
) # see vignette("lintr")
encoding: "UTF-8"
3 changes: 2 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ repos:
- repo: https://github.com/lorenzwalthert/precommit
rev: v0.3.2
hooks:
- id: readme-rmd-rendered
- id: no-browser-statement
- id: no-debug-statement
- id: parsable-R
- id: use-tidy-description
- id: style-files
- id: lintr
7 changes: 6 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,18 @@ Description: This package bundles the analysis and visualization scripts
used to process the datasets included for the DSCI 799 capstone project
for creating predictive models. Datasets must be obtained through external
sources.
License: MIT + file LICENSE + file LICENSE-DOCS
License: MIT + file LICENSE
URL: https://github.com/rimij405/r-capstone-code
BugReports: https://github.com/rimij405/r-capstone-code/issues
Suggests:
renv,
testthat (>= 3.0.0)
Config/testthat/edition: 3
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
SystemRequirements: python >= 3.12.0 https://www.python.org/downloads/release/python-3120/
Depends:
R (>= 4.3.0)
Imports:
targets
62 changes: 62 additions & 0 deletions _targets.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Created by use_targets(). Follow the comments below to fill in this target
# script. Then follow the manual to check and run the pipeline:
# https://books.ropensci.org/targets/walkthrough.html#inspect-the-pipeline

# nolint start: commented_code_linter, trailing_whitespace_linter.

# Load packages required to define the pipeline:
library(targets)
# library(tarchetypes) # Load other packages as needed.

# Set target options:
tar_option_set(
packages = c("tibble") # packages that your targets need to run
# format = "qs", # Optionally set the default storage format. qs is fast.
#
# For distributed computing in tar_make(), supply a {crew} controller as
# discussed at https://books.ropensci.org/targets/crew.html. Choose a
# controller that suits your needs. For example, the following sets a
# controller with 2 workers which will run as local R processes:
#
# controller = crew::crew_controller_local(workers = 2)
#
# Alternatively, if you want workers to run on a high-performance computing
# cluster, select a controller from the {crew.cluster} package. The following
# example is a controller for Sun Grid Engine (SGE).
#
# controller = crew.cluster::crew_controller_sge( workers = 50, # Many
# clusters install R as an environment module, and you can load it # with
# the script_lines argument. To select a specific verison of R, # you may
# need to include a version string, e.g. "module load R/4.3.0". # Check
# with your system administrator if you are unsure. script_lines = "module
# load R" )
#
# Set other options as needed.
)

# tar_make_clustermq() is an older (pre-{crew}) way to do distributed computing
# in {targets}, and its configuration for your machine is below.
# options(clustermq.scheduler = "multicore")

# tar_make_future() is an older (pre-{crew}) way to do distributed computing in
# {targets}, and its configuration for your machine is below. Install packages
# {{future}}, {{future.callr}}, and {{future.batchtools}} to allow use_targets()
# to configure tar_make_future() options.

# Run the R scripts in the R/ folder with your custom functions:
tar_source()
# source("other_functions.R") # Source other scripts as needed.

# Replace the target list below with your own:
list(
tar_target(
name = data,
command = tibble(x = rnorm(100), y = rnorm(100))
# format = "feather" # efficient storage for large data frames
),
tar_target(
name = model,
command = coefficients(lm(y ~ x, data = data))
)
)
# nolint end
5 changes: 5 additions & 0 deletions _targets/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*
!.gitignore
!meta
meta/*
!meta/meta
4 changes: 4 additions & 0 deletions _targets/meta/meta
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name|type|data|command|depend|seed|path|time|size|bytes|format|repository|iteration|parent|children|seconds|warnings|error
.Random.seed|object|192e3abaec7d64a5|||||||||||||||
data|stem|0d3f14a3a96b3ff8|43fae4011a0626f4|ef46db3751d8e999|1588979285||t19697.9230297838s|d07e2e962de596ec|1750|rds|local|vector|||0.006||
model|stem|1636c25df1da2510|ae83bc723fe2997c|5d1b10f263532bdf|1816327236||t19697.9230298995s|4bab66ba4bee4440|108|rds|local|vector|||0.003||
21 changes: 21 additions & 0 deletions bin/check
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash

# Installation directory.
SCRIPT_DIR="$(realpath "${0%/*}")"
INSTALL_DIR="$(realpath "${SCRIPT_DIR}/../inst")"

# Ensure installation directory exists.
if [ ! -d "${INSTALL_DIR}" ]; then
mkdir -p "${INSTALL_DIR}"
fi

# Copy files into the `inst/` directory.
files=("_targets.R" "CHANGELOG.md" "CITATION" "CITATION.cff")

for file in "${files[@]}"; do
cp "${SCRIPT_DIR}/../${file}" "${INSTALL_DIR}/${file}"
done

# Run check.
/usr/bin/R --no-echo --no-restore -e "devtools::check()" |
tee rcmdcheck.log
10 changes: 10 additions & 0 deletions bin/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env Rscript

# This is a helper script to run the pipeline.
# Choose how to execute the pipeline below.
# See https://books.ropensci.org/targets/hpc.html
# to learn about your options.

targets::tar_make()
# targets::tar_make_clustermq(workers = 2) # nolint
# targets::tar_make_future(workers = 2) # nolint
13 changes: 13 additions & 0 deletions bin/run-background
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

# <!-- This file was auto-generated by `targets::use_targets()` -->

# Submit the pipeline as a background process with ./run.sh
# module load R # Uncomment if R is an environment module.
nohup nice -4 R CMD BATCH ./../run.R &

# Change the nice level above as appropriate
# for your situation and system.

# Removing .RData is recommended.
# rm -f .RData
4 changes: 4 additions & 0 deletions inst/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
_targets.R
CHANGELOG.md
CITATION
CITATION.cff
Loading

0 comments on commit 849b2c2

Please sign in to comment.