{"id":13857440,"url":"https://github.com/wlandau/targets-minimal","last_synced_at":"2025-03-20T00:31:08.356Z","repository":{"id":54494057,"uuid":"273919929","full_name":"wlandau/targets-minimal","owner":"wlandau","description":"A minimal example data analysis project with the targets R package","archived":false,"fork":false,"pushed_at":"2022-03-30T12:46:15.000Z","size":509,"stargazers_count":58,"open_issues_count":0,"forks_count":19,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-08-06T03:03:59.682Z","etag":null,"topics":["data-science","high-performance-computing","pipeline","r","reproducibility","reproducible-research","rstats","statistics","targets","workflow"],"latest_commit_sha":null,"homepage":"https://rstudio.cloud/project/1430691","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wlandau.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-06-21T14:25:03.000Z","updated_at":"2024-04-21T16:27:29.000Z","dependencies_parsed_at":"2022-08-13T17:40:46.645Z","dependency_job_id":null,"html_url":"https://github.com/wlandau/targets-minimal","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wlandau%2Ftargets-minimal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wlandau%2Ftargets-minimal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wlandau%2Ftargets-minimal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wlandau%2Ftargets-minimal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wlandau","download_url":"https://codeload.github.com/wlandau/targets-minimal/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219866012,"owners_count":16555916,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["data-science","high-performance-computing","pipeline","r","reproducibility","reproducible-research","rstats","statistics","targets","workflow"],"created_at":"2024-08-05T03:01:37.095Z","updated_at":"2024-10-10T18:25:03.255Z","avatar_url":"https://github.com/wlandau.png","language":"R","funding_links":[],"categories":["R"],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\"\n)\n```\n\n# `targets` package minimal example\n\n[![Launch RStudio Cloud](https://img.shields.io/badge/RStudio-Cloud-blue)](https://rstudio.cloud/project/1430691)\n\nThis repository is an example data analysis workflow with [`targets`](https://docs.ropensci.org/targets). The pipeline reads the data from a file, preprocesses it, visualizes it, and fits a regression model. \n\n## How to access\n\nYou can try out this example project as long as you have a browser and an internet connection. [Click here](https://rstudio.cloud/project/1430691) to navigate your browser to an RStudio Cloud instance. Alternatively, you can clone or download this code repository and install the R packages [listed here](https://github.com/wlandau/targets-minimal/blob/03835c2aa4679dcf3f28c623a06d7505b18bee17/DESCRIPTION#L25-L30).\n\n## How to run\n\n1. Open the R console and call `renv::restore()` to install the required R packages.\n2. call the [`tar_make()`](https://wlandau.github.io/targets/reference/tar_make.html) function to run the pipeline.\n3. Then, call `tar_read(hist)` to retrieve the histogram. \n4. Experiment with [other functions](https://wlandau.github.io/targets/reference/index.html) such as [`tar_visnetwork()`](https://wlandau.github.io/targets/reference/tar_visnetwork.html) to learn how they work.\n\n## File structure\n\nThe most important files are:\n\n```{r, eval = FALSE}\n├── _targets.R\n├── R/\n├──── functions.R\n├── data/\n├──── raw_data.csv\n└── index.Rmd\n```\n\nFile | Purpose\n---|---\n[`_targets.R`](https://github.com/wlandau/targets-minimal/blob/main/_targets.R) | The special R script that declares the [`targets`](https://docs.ropensci.org/targets) pipeline. See `tar_script()` for details.\n[`R/functions.R`](https://github.com/wlandau/targets-minimal/blob/main/R/functions.R) | An R script with user-defined functions. Unlike [`_targets.R`](https://github.com/wlandau/targets-minimal/blob/main/_targets.R), there is nothing special about the name or location of this script. In fact, for larger projects, it is good practice to partition functions into multiple files.\n[`data/raw_data.csv`](https://github.com/wlandau/targets-minimal/blob/main/data/raw_data.csv) | The raw `airquality` dataset.\n[`index.Rmd`](https://github.com/wlandau/targets-minimal/blob/main/index.Rmd): an R Markdown report that reruns in the pipeline whenever the histogram of ozone changes ([details](https://books.ropensci.org/targets/files.html#literate-programming)).\n\n## Continuous deployment\n\nMinimal pipelines with low resource requirements are appropriate for continuous deployment. For example, when this particular GitHub repository is updated, its `targets` pipeline runs in a [GitHub Actions workflow](https://github.com/wlandau/targets-minimal/actions). The workflow pushes the results to the [`targets-runs`](https://github.com/wlandau/targets-minimal/tree/targets-runs) branch, and [GitHub Pages](https://pages.github.com/) hosts the latest version of the rendered R Markdown report at \u003chttps://wlandau.github.io/targets-minimal/\u003e. Subsequent runs restore the output files from the previous run so that up-to-date targets do not rebuild. Follow these steps to set up continuous deployment for your own minimal pipeline:\n\n1. Ensure your project stays within the storage and compute limitations of GitHub (i.e. your pipeline is minimal). For storage, you may choose the [AWS-backed storage formats](https://books.ropensci.org/targets/cloud.html#storage) (e.g. `tar_target(..., format = \"aws_qs\")`) for large outputs to reduce the burden on GitHub storage.\n2. Ensure GitHub Actions are enabled in the Settings tab of your GitHub repository's website.\n3. Set up your project with [`renv`](https://rstudio.github.io/renv/) ([details here](https://rstudio.github.io/renv/articles/ci.html)).\n    * Call `targets::tar_renv(extras = character(0))` to write a `_packages.R` file to expose hidden dependencies.\n    * Call `renv::init()` to initialize the `renv` lockfile `renv.lock` or `renv::snapshot()` to update it.\n    * Commit `renv.lock` to your Git repository.\n4. Write the [`.github/workflows/targets.yaml`](https://github.com/wlandau/targets-minimal/blob/main/.github/workflows/targets.yaml) workflow file using `targets::tar_github_actions()` and commit this file to Git.\n5. Push to GitHub. A GitHub Actions workflow should run the pipeline and upload the results to the `targets-runs` branch of your repository. Subsequent runs should add new commits but not necessarily rerun targets.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwlandau%2Ftargets-minimal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwlandau%2Ftargets-minimal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwlandau%2Ftargets-minimal/lists"}