{"id":27204489,"url":"https://github.com/simonrolph/minimal_targets_demo","last_synced_at":"2025-04-09T22:58:32.035Z","repository":{"id":222688074,"uuid":"758106061","full_name":"simonrolph/minimal_targets_demo","owner":"simonrolph","description":"A minimal targets demonstrator","archived":false,"fork":false,"pushed_at":"2024-02-22T17:06:51.000Z","size":2119,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-09T22:58:27.637Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/simonrolph.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-02-15T16:27:47.000Z","updated_at":"2024-02-15T16:29:58.000Z","dependencies_parsed_at":"2024-02-15T17:54:56.914Z","dependency_job_id":null,"html_url":"https://github.com/simonrolph/minimal_targets_demo","commit_stats":null,"previous_names":["simonrolph/minimal_targets_demo"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonrolph%2Fminimal_targets_demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonrolph%2Fminimal_targets_demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonrolph%2Fminimal_targets_demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonrolph%2Fminimal_targets_demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simonrolph","download_url":"https://codeload.github.com/simonrolph/minimal_targets_demo/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248125569,"owners_count":21051767,"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":[],"created_at":"2025-04-09T22:58:31.339Z","updated_at":"2025-04-09T22:58:32.011Z","avatar_url":"https://github.com/simonrolph.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"# A very minimal {targets} demonstration and exercises\n\n## Overview\n\nThis is an introduction to {targets}. The targets package is a Make-like pipeline tool for statistics and data science in R. https://books.ropensci.org/targets/ \n\nThe philosophy is for this demonstration is to be **as simple as possible**, and focus on the key aspects of why making pipelines is a good idea.\n\nUnlike most pipeline tools, which are language agnostic or Python-focused, the targets package allows data scientists and researchers to work entirely within R. targets implicitly nudges users toward a clean, function-oriented programming style that fits the intent of the R language and helps practitioners maintain their data analysis projects.\n\nThere are some slides in `/slides` which I use for introducing the concepts.\n\n## Demonstration - getting to grips with {targets}\n\nIn order to demonstrate {targets} functionality, I show how a basic R script can be written as a {targets} pipeline. This pipeline takes a csv of two numeric variables, `x` and `y` and produces a plot with a linear model prediction.\n\nThe first script `0_generate_test_data.R` sets up some example data to use in the demonstration. It creates an `inputs` and `outputs` folders (which are ignored by git).\n\nI first walk through how you might write this script with a \"business as usual\" approach, no {targets}. This is demonstrated in `1_non_targets_version.R` and does all the things you'd expect how it might work if you didn't use targets.\n\nI then use `2_targets_version.R` as a reference for myself but don't show it to participants. Encourge users to create their own `_targets.R` file and create the pipeline step by step. These are roughly the steps I walk through to demonstrate the usage of {targets}:\n\n - Create a `_targets.R` file\n - Add `library(targets)`\n - Add `list()` to the end of the file\n - Add `tar_target(data_file, \"inputs/data.csv\",format = \"file\")` to make a 1 node pipeline, explain the importance of `format=\"file\"`\n - Then do `tar_visnetwork()` then `tar_make()` then `tar_visnetwork()` again to show how it updates the graph\n - Add `tar_target(data, read.csv(data_file))`\n - Define a function to model the data and add `tar_target(data_model, model_data(data))`. Do `tar_visnetwork()` to show how functions appear.\n - Explain how the tracking works, take a look in the `targets` folder and show `tar_read()`\n - Add the rest of the pipeline, including explaining how outputs (noting how the function returns file path not R object), highlight use of `format=\"file\"` again.\n - Get participants to ask questions and modify pipeline in response to demosntrate your answer\n\n## Extra bits\n\n`3_static_branching.R` shows how you can do static branching by subsetting the iris dataset by species and producing a species for each plot.\n\nOther things you might want to cover:\n\n - How to put your R functions in separate files (eg. `R/functions.R`) and source them from `_targets.R` to help you organise your code.\n - How to have multiple targets dependent on the same target\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimonrolph%2Fminimal_targets_demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimonrolph%2Fminimal_targets_demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimonrolph%2Fminimal_targets_demo/lists"}