You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: exercises/functions/03-functions-checks.qmd
+5-5Lines changed: 5 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -95,7 +95,7 @@ is.numeric(DF$numbers)
95
95
96
96
## Filters
97
97
98
-
### Exercise: `filter_islands()`
98
+
### Exercise: filter_islands()
99
99
100
100
First, write a function to filter a data.frame, providing the column name for the data to be filtered and the values to filter on. Use the example data that we prepared with our `prepare_csv` function.
101
101
@@ -131,7 +131,7 @@ Pass the data.frame's column that you want to filter on to the plot function's f
131
131
</details>
132
132
133
133
<details>
134
-
<summary>Hints: `dplyr`</summary>
134
+
<summary>Hints: dplyr</summary>
135
135
<hr>
136
136
This function has one step: taking an input data.frame and filtering across a single column.
### Exercise: writing checks for `filter_islands()`
151
+
### Exercise: writing checks for filter_islands()
152
152
::: callout-note
153
153
## Objective
154
154
Write and test a complete function.
@@ -183,15 +183,15 @@ of metaprogramming. The Advanced R book has a detailed section on this concept.
183
183
184
184
### Bonus
185
185
186
-
#### Writing checks for `prepare_csv()`
186
+
#### Writing checks for prepare_csv()
187
187
188
188
Instruction: add the following checks to your `prepare_csv()` function and
189
189
test them in your test script (`tests/test_prepare_csv.R`).
190
190
191
191
- check if the path points to a file that exists
192
192
- before returning the object, check that it is a data.frame
193
193
194
-
#### More informative errors with `stopifnot()`
194
+
#### More informative errors with stopifnot()
195
195
196
196
Instruction: Write more informative errors for your `stopifnot()` checks using the following syntax: `stopifnot("error message" = logical_statement)`. Think about your user (either someone else or future you) - what would help them understand and resolve this error?
Copy file name to clipboardExpand all lines: exercises/targets/01-targets-setup.qmd
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
# Setup
1
+
# Setting up targets
2
2
3
3
::: callout-tip
4
4
## Learning Goals
@@ -11,7 +11,7 @@ This set of exercises are centered around an approach to setting up your project
11
11
12
12
A {targets} pipeline is declared in the `_targets.R` file in the root of your project's directory. We'll also set up a central place to put all our of required packages that helps us keep track of them, and will later make it easier to set up {renv}.
13
13
14
-
## `_targets.R`
14
+
## _targets.R
15
15
16
16
The `_targets.R` is where we declare our {targets} pipeline. It is an R file saved in the root directory of your project. The generalized structure of a `_targets.R` file is:
17
17
@@ -37,7 +37,7 @@ c(
37
37
)
38
38
```
39
39
40
-
### Exercise: `_targets.R`
40
+
### Exercise: _targets.R
41
41
42
42
::: callout-note
43
43
## Objective
@@ -58,7 +58,7 @@ To declare which packages we need across all our functions, we have two main opt
58
58
We prefer the second approach because it keeps our `_targets.R` tidier, and helps us setup {renv} package versioning and {conflicted} later. You might find your list of packages gets long, and this gets them out of our way. You can also use this script when you are exploring your results later - source the `packages.R` script and you will have all your required packages.
Run the {targets} pipeline with `tar_make()`. The pipeline is run in a new external R process, which means that `tar_make()` doesn't impact your current workspace and, more importantly, is not influenced by your current workspace. This totally isolated environment is how {targets} offers us a truly reproducible approach - only things defined in the `_targets.R` script (or sourced within it) are considered.
69
69
70
70
71
-
### Exercise: `tar_make()`
71
+
### Exercise: tar_make()
72
72
73
73
::: callout-note
74
74
## Objective
@@ -91,11 +91,11 @@ tar_make()
91
91
</details>
92
92
93
93
94
-
## `tar_read()`, `tar_load()`
94
+
## tar_read(), tar_load()
95
95
96
96
To look at results from the {targets} pipeline, use `tar_read()` and `tar_load()`. `tar_read()` reads targets without saving them as an object in your environment and `tar_load()` loads the object directly to your environment using the name of the target as the object.
97
97
98
-
### Exercise: `tar_read()`, `tar_load()`
98
+
### Exercise: tar_read(), tar_load()
99
99
100
100
::: callout-note
101
101
## Objective
@@ -122,11 +122,11 @@ tar_read(plotted)
122
122
</details>
123
123
124
124
125
-
## `tar_meta()`
125
+
## tar_meta()
126
126
127
127
The metadata related to the {targets} pipeline is accessible using the function `tar_meta()`.
Copy file name to clipboardExpand all lines: exercises/targets/03-targets-extensions.qmd
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
# Extensions
1
+
# Targets extensions
2
2
3
3
Let's look at a {targets} pipeline that more closely resembles what a full project would be including figures, model, output, tables and a manuscript object. We'll start with a demo, so we can show off some of the power and extended features of {targets}, then we can work through it piece by piece to explain the details.
0 commit comments