### Installing Development Version of tarchetypes (R) Source: https://github.com/ropensci/tarchetypes/blob/main/CONTRIBUTING.md This R command installs the latest development version of the `tarchetypes` package directly from its GitHub repository. It is recommended for bug reporting to verify if an issue persists in the most recent unreleased code. Requires the `remotes` package. ```R remotes::install_github("ropensci/tarchetypes") ``` -------------------------------- ### Installing tarchetypes R Package Source: https://github.com/ropensci/tarchetypes/blob/main/README.md This snippet provides commands for installing the `tarchetypes` R package from different sources: CRAN for the release version, GitHub for the development version, and rOpenSci's development repository for another development option. ```R install.packages("tarchetypes") ``` ```R remotes::install_github("ropensci/tarchetypes") ``` ```R install.packages("tarchetypes", repos = "https://dev.ropensci.org") ``` -------------------------------- ### Defining a targets Pipeline with tar_plan in R Source: https://github.com/ropensci/tarchetypes/blob/main/README.md This snippet illustrates an alternative, `drake`-like syntax for defining a `targets` pipeline using `tar_plan()`. It allows users to specify targets as name/command pairs, simplifying the pipeline definition. It includes examples of file targets, data processing, plot generation, statistical modeling, and R Markdown report rendering. ```R tar_plan( tar_file(raw_data_file, "data/raw_data.csv", format = "file"), # Simple drake-like syntax: raw_data = read_csv(raw_data_file, col_types = cols()), data =raw_data %>% mutate(Ozone = replace_na(Ozone, mean(Ozone, na.rm = TRUE))), hist = create_plot(data), fit = biglm(Ozone ~ Wind + Temp, data), # Needs tar_render() because it is a target archetype: tar_render(report, "report.Rmd") ) ``` -------------------------------- ### Checking Code Formatting with lintr (R) Source: https://github.com/ropensci/tarchetypes/blob/main/CONTRIBUTING.md This R function, part of the `lintr` package, is used to check the formatting of the package's code against the tidyverse style guide. It helps ensure code consistency and readability for contributions. Requires the `lintr` package. ```R lint_package() ``` -------------------------------- ### Running Good Practice Checks with goodpractice (R) Source: https://github.com/ropensci/tarchetypes/blob/main/CONTRIBUTING.md This R command evaluates the package against a set of good practice recommendations using the `goodpractice` package. It helps identify potential issues related to code quality, documentation, and testing, ensuring high-quality contributions. Requires the `goodpractice` package. ```R goodpractice::gp() ``` -------------------------------- ### Executing and Inspecting Grouped Data Targets in R Source: https://github.com/ropensci/tarchetypes/blob/main/README.md This R console output demonstrates the execution of a `targets` pipeline that utilizes `tarchetypes` for grouped data frames. It shows the `tar_make()` command initiating the pipeline, followed by the dispatch and completion of individual data branches. The `tar_read()` calls illustrate how to access specific row groups from the branched target, confirming the successful grouping and processing of data subsets. ```R library(targets) tar_make() #> ▶ dispatched target data #> ● completed target data [0.007 seconds] #> ▶ dispatched branch group_b3d7d010 #> ● completed branch group_b3d7d010 [0 seconds] #> ▶ dispatched branch group_6a76c5c0 #> ● completed branch group_6a76c5c0 [0 seconds] #> ▶ dispatched branch group_164b16bf #> ● completed branch group_164b16bf [0 seconds] #> ▶ dispatched branch group_f5aae602 #> ● completed branch group_f5aae602 [0 seconds] #> ● completed pattern group #> ▶ completed pipeline [0.104 seconds] # First row group: tar_read(group, branches = 1) #> # A tibble: 3 × 4 #> var1 var2 rep tar_group #> #> 1 a c 1 1 #> 2 a c 2 1 #> 3 a c 3 1 # Second row group: tar_read(group, branches = 2) #> # A tibble: 3 × 4 #> var1 var2 rep tar_group #> #> 1 a d 1 2 #> 2 a d 2 2 #> 3 a d 3 2 ``` -------------------------------- ### Defining a targets Pipeline with tar_target and tar_render in R Source: https://github.com/ropensci/tarchetypes/blob/main/README.md This snippet demonstrates a basic `targets` pipeline definition using `list()` to combine `tar_target()` for data objects and `tar_render()` for R Markdown reports. `tar_render()` automatically scans the R Markdown file for dependencies on other targets, ensuring they are processed in the correct order. ```R library(targets) library(tarchetypes) list( tar_target(dataset, data.frame(x = letters)), tar_render(report, "report.Rmd") ) ``` -------------------------------- ### Checking Package Code Coverage with covr (R) Source: https://github.com/ropensci/tarchetypes/blob/main/CONTRIBUTING.md This R command calculates the code coverage for the entire package using the `covr` package. Contributors should ensure that automated tests cover all new or changed functionality introduced in their pull requests. Requires the `covr` package. ```R covr::package_coverage() ``` -------------------------------- ### Citing tarchetypes R Package Source: https://github.com/ropensci/tarchetypes/blob/main/README.md This snippet demonstrates how to obtain citation information for the `tarchetypes` R package using the `citation()` function. It outputs the recommended citation format for publications, including a BibTeX entry for LaTeX users. ```R citation("tarchetypes") ``` -------------------------------- ### Manually Rendering R Markdown Reports in targets (Without tarchetypes) in R Source: https://github.com/ropensci/tarchetypes/blob/main/README.md This R code snippet demonstrates how to manually define a `targets` pipeline entry for rendering an R Markdown report. It explicitly lists dependencies (like `dataset`), handles file paths, and configures `rmarkdown::render()` parameters such as `knit_root_dir`. This approach requires careful management of file tracking and dependencies, highlighting the complexity `tarchetypes` aims to simplify. ```R library(targets) list( tar_target(dataset, data.frame(x = letters)), tar_target( report, { # Explicitly mention the symbol `dataset`. list(dataset) # Return relative paths to keep the project portable. fs::path_rel( # Need to return/track all input/output files. c( rmarkdown::render( input = "report.Rmd", # Always run from the project root # so the report can find _targets/. knit_root_dir = getwd(), quiet = TRUE ), "report.Rmd" ) ) }, # Track the input and output files. format = "file", # Avoid building small reports on HPC. deployment = "main" ) ) ``` -------------------------------- ### Running Overall Package Checks with devtools (R) Source: https://github.com/ropensci/tarchetypes/blob/main/CONTRIBUTING.md This R command performs comprehensive checks on the package, including R CMD check, using the `devtools` package. It's a crucial step to ensure the package adheres to CRAN policies and best practices before submitting contributions. Requires the `devtools` package. ```R devtools::check() ``` -------------------------------- ### Defining Grouped Data Targets with tar_group_by in R Source: https://github.com/ropensci/tarchetypes/blob/main/README.md This R code snippet defines a `targets` pipeline (`_targets.R`) that uses `tarchetypes::tar_group_by()` to create row groups from a generated dataset. Downstream dynamic targets will automatically branch over these defined groups, enabling efficient parallel processing of data subsets. It demonstrates how to set up a data production function and then group its output by specified variables. ```R library(targets) library(tarchetypes) produce_data <- function() { expand.grid(var1 = c("a", "b"), var2 = c("c", "d"), rep = c(1, 2, 3)) } list( tar_group_by(data, produce_data(), var1, var2), tar_target(group, data, pattern = map(data)) ) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.