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: content/blog/teach-tidyverse-2021/index.Rmd
+10-9
Original file line number
Diff line number
Diff line change
@@ -57,18 +57,18 @@ library(tidyverse)
57
57
58
58
Before we dive into specific package functionality updates, I'd like to highlight two new teaching and learning resources:
59
59
60
-
-**Cheatsheets:** Some of the most popular learning resources for tidyverse are the cheatsheets and many of which have recently been updated. Huge thanks to our intern [Averi Perny](https://twitter.com/avperny) on the fantastic work on this project! You can read more about the updates [here](https://blog.rstudio.com/2021/08/23/cheat-sheet-updates/) and find the new cheatsheets [here](https://www.rstudio.com/resources/cheatsheets/).
60
+
-**Cheatsheets:** Some of the most popular learning resources for the tidyverse are the cheatsheets, many of which have recently been updated. Huge thanks to our intern [Averi Perny](https://twitter.com/avperny) on the fantastic work on this project! You can read more about the updates [here](https://blog.rstudio.com/2021/08/23/cheat-sheet-updates/) and find the new cheatsheets [here](https://www.rstudio.com/resources/cheatsheets/).
61
61
-**ggplot2 FAQ:** A new resource that might be useful for learners is the FAQ we've recently developed for ggplot2, which you can access [here](https://ggplot2.tidyverse.org/articles/). These were compiled based on popular questions on StackOverflow and RStudio Community. Each question is accompanied with a short answer as well as an expanded example.
62
62
63
63
## Lifecycle stages
64
64
65
65
The [**lifecycle**](https://lifecycle.r-lib.org/) package is used to manage the lifecycle of functions and features within the tidyverse, with clear messaging about what is still experimental and what the tidyverse team is moving away from in the future.
66
-
But instead of focusing on the package that implements this concept, when teaching I recommend focusing on the stages of the lifecycle instead.
66
+
But instead of focusing on the package that implements this concept, when teaching, I recommend focusing on the stages of the lifecycle instead.
67
67
These are *experimental*, *stable*, *deprecated*, and *superseded*.
68
-
The lifecycle stages are a useful guide for teaching because they help you see what the tidyverse is moving forward and what it's moving away from.
68
+
The lifecycle stages are a useful guide for teaching because they help you see what the tidyverse is moving toward and what it's moving away from.
69
69
Being aware of the lifecycle stages (and their associated badges) can be helpful as you review and revise your teaching materials or as you consider incorporating new tooling into your teaching.
70
70
71
-
The diagram below depicts the lifecycle of the various stages of functions and packages in the tidyverse.
71
+
The diagram below depicts the lifecycle stages of functions and packages in the tidyverse.
72
72
73
73

74
74
@@ -77,7 +77,7 @@ Let's discuss each of these stages in detail, along with recommendations on how
77
77
- <imgsrc="lifecycle-stable.svg"alt="Stable"style="vertical-align:middle"/> Stable indicates that breaking changes will be avoided where possible, and they're only made if the long term benefit of such a change exceeds the short term pain of changing existing code.
78
78
If breaking changes are needed, they will occur gradually.
79
79
This is the default state for most functions in the tidyverse and hence the badge is generally not shown.
80
-
Teaching tip: teach away any stable functions, they're here to stay for the long run!
80
+
Teaching tip: feel free to teach any stable functions, they're here to stay for the long run!
81
81
82
82
- <imgsrc="lifecycle-deprecated.svg"alt="Deprecated"style="vertical-align:middle"/> If a function is noted as deprecated, this means a better alternative is available and this function is scheduled for removal.
83
83
Generally functions will first be soft deprecated and then deprecated.
@@ -118,17 +118,18 @@ If you'd like to learn more about the tidyverse lifecycle, I recommend the follo
118
118
The [**reprex**](https://reprex.tidyverse.org/) package helps users create **repr**oducible **ex**amples for posting to GitHub issues, StackOverflow, in Slack messages or snippets, or even to paste into PowerPoint or Keynote slides by placing the code to be shared in your clipboard.
119
119
I find reprex very useful when teaching because it helps my students provide me with broken code in a way that makes it as easy as possible for me (and for other students in the class) to help them.
120
120
121
-
There has been [many](https://reprex.tidyverse.org/news/index.html#reprex-1-0-0-2021-01-27)[exciting](https://reprex.tidyverse.org/news/index.html#reprex-2-0-0-2021-04-02) developments in reprex over the year.
121
+
There have been [many](https://reprex.tidyverse.org/news/index.html#reprex-1-0-0-2021-01-27)[exciting](https://reprex.tidyverse.org/news/index.html#reprex-2-0-0-2021-04-02) developments in reprex over the year.
122
122
The one that is perhaps most relevant to teaching are improvements that make it easier to use reprex when working in [RStudio Server](https://www.rstudio.com/products/rstudio/#rstudio-server) and [RStudio Cloud](https://rstudio.cloud/) as well as those that allow using local data when creating a reprex.
123
123
124
-
Many courses teache R using RStudio Server or RStudio Cloud since this approach circumvents the need for students to install software and allows the instructor to have full control over the R environment their students are learning in.
124
+
Many courses teach R using RStudio Server or RStudio Cloud since this approach circumvents the need for students to install software and allows the instructor to have full control over the R environment their students are learning in.
125
125
When working in these environments, the R code is running in a web browser and for security reasons it's not possible for reprex to place code on your system clipboard.
126
126
When creating a reprex in these environments, you can now simply select the relevant code, and run `reprex()`.
127
127
This will create a `.md` file containing the contents of the reprex, ready for you to copy via Cmd/Ctrl+C.
128
128
129
129
<imgsrc="reprex-cloud.png"alt="On the left: RStudio Cloud window with an R script with two lines of code highlighted. On the right: Result after running reprex() in the Console, including a new markdown file with the name vivid-eider_reprex.md that includes the code and the resulting output, commented out, and selected, ready to be copy pasted elsewhere. The viewer pane on the bottom right shows the stylized result of the reprex."width="1000"/>
130
130
131
-
Another development that will help students, particularly those working on an assignment involving a local data file, create reprexes is the new `wd` argument to set working directory of the reprex.[^2]
131
+
The new `wd` argument can help students create reprexes when they are working on an assignment involving a local data file.
132
+
When `reprex(wd = ".")`, the reprex will be executed in the current working directory.[^2]
132
133
Writing a reproducible example with a minimal dataset is better practice, but this can be quite difficult for new learners.
133
134
Being able to easily use local data will make it easier for them to benefit from other aspects of reprex earlier on.
134
135
@@ -417,7 +418,7 @@ cyl_summary %>% show_query()
417
418
```
418
419
419
420
With recent updates, dtplyr can also translate some tidyr functions to data.table, e.g., `pivot_wider()`.
420
-
In the following example the process is the same: start with `lazy_dt()`, write a data transformation step using tidyverse code, view the resut with `as_tibble()`, and view the query with `show_query()`.
421
+
In the following example the process is the same: start with `lazy_dt()`, write a data transformation step using tidyverse code, view the result with `as_tibble()`, and view the query with `show_query()`.
Copy file name to clipboardExpand all lines: content/blog/teach-tidyverse-2021/index.md
+9-9
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ photo:
17
17
# one of: "deep-dive", "learn", "package", "programming", or "other"
18
18
categories: [learn]
19
19
tags: [tidyverse, teaching]
20
-
rmd_hash: e3970444e051b714
20
+
rmd_hash: 11fdf5ca653acb05
21
21
22
22
---
23
23
@@ -66,20 +66,20 @@ Let's get started!
66
66
67
67
Before we dive into specific package functionality updates, I'd like to highlight two new teaching and learning resources:
68
68
69
-
-**Cheatsheets:** Some of the most popular learning resources for tidyverse are the cheatsheets and many of which have recently been updated. Huge thanks to our intern [Averi Perny](https://twitter.com/avperny) on the fantastic work on this project! You can read more about the updates [here](https://blog.rstudio.com/2021/08/23/cheat-sheet-updates/) and find the new cheatsheets [here](https://www.rstudio.com/resources/cheatsheets/).
69
+
-**Cheatsheets:** Some of the most popular learning resources for the tidyverse are the cheatsheets, many of which have recently been updated. Huge thanks to our intern [Averi Perny](https://twitter.com/avperny) on the fantastic work on this project! You can read more about the updates [here](https://blog.rstudio.com/2021/08/23/cheat-sheet-updates/) and find the new cheatsheets [here](https://www.rstudio.com/resources/cheatsheets/).
70
70
-**ggplot2 FAQ:** A new resource that might be useful for learners is the FAQ we've recently developed for ggplot2, which you can access [here](https://ggplot2.tidyverse.org/articles/). These were compiled based on popular questions on StackOverflow and RStudio Community. Each question is accompanied with a short answer as well as an expanded example.
71
71
72
72
## Lifecycle stages
73
73
74
-
The [**lifecycle**](https://lifecycle.r-lib.org/) package is used to manage the lifecycle of functions and features within the tidyverse, with clear messaging about what is still experimental and what the tidyverse team is moving away from in the future. But instead of focusing on the package that implements this concept, when teaching I recommend focusing on the stages of the lifecycle instead. These are *experimental*, *stable*, *deprecated*, and *superseded*. The lifecycle stages are a useful guide for teaching because they help you see what the tidyverse is moving forward and what it's moving away from. Being aware of the lifecycle stages (and their associated badges) can be helpful as you review and revise your teaching materials or as you consider incorporating new tooling into your teaching.
74
+
The [**lifecycle**](https://lifecycle.r-lib.org/) package is used to manage the lifecycle of functions and features within the tidyverse, with clear messaging about what is still experimental and what the tidyverse team is moving away from in the future. But instead of focusing on the package that implements this concept, when teaching, I recommend focusing on the stages of the lifecycle instead. These are *experimental*, *stable*, *deprecated*, and *superseded*. The lifecycle stages are a useful guide for teaching because they help you see what the tidyverse is moving toward and what it's moving away from. Being aware of the lifecycle stages (and their associated badges) can be helpful as you review and revise your teaching materials or as you consider incorporating new tooling into your teaching.
75
75
76
-
The diagram below depicts the lifecycle of the various stages of functions and packages in the tidyverse.
76
+
The diagram below depicts the lifecycle stages of functions and packages in the tidyverse.
77
77
78
78

79
79
80
80
Let's discuss each of these stages in detail, along with recommendations on how you might consider them in the context of teaching:
81
81
82
-
- <imgsrc="lifecycle-stable.svg"alt="Stable"style="vertical-align:middle"/> Stable indicates that breaking changes will be avoided where possible, and they're only made if the long term benefit of such a change exceeds the short term pain of changing existing code. If breaking changes are needed, they will occur gradually. This is the default state for most functions in the tidyverse and hence the badge is generally not shown. Teaching tip: teach away any stable functions, they're here to stay for the long run!
82
+
- <imgsrc="lifecycle-stable.svg"alt="Stable"style="vertical-align:middle"/> Stable indicates that breaking changes will be avoided where possible, and they're only made if the long term benefit of such a change exceeds the short term pain of changing existing code. If breaking changes are needed, they will occur gradually. This is the default state for most functions in the tidyverse and hence the badge is generally not shown. Teaching tip: feel free to teach any stable functions, they're here to stay for the long run!
83
83
84
84
- <img src="lifecycle-deprecated.svg" alt="Deprecated" style="vertical-align:middle"/> If a function is noted as deprecated, this means a better alternative is available and this function is scheduled for removal. Generally functions will first be soft deprecated and then deprecated. Very important functions that become deprecated might next be defunct, which means that function continues to exist but the deprecation warning turns into an error. An example of a deprecated function is [`tibble::data_frame()`](https://tibble.tidyverse.org/reference/deprecated.html), with the preferred alternative [`tibble::tibble()`](https://tibble.tidyverse.org/reference/tibble.html). Arguments to functions can also be deprecated, e.g., in [`tidyr::nest()`](https://tidyr.tidyverse.org/reference/nest.html) the new argument `new_col` makes the former `.key` argument not needed, and hence `.key` is deprecated. You should avoid teaching functions that are deprecated and correct their usage in your students' code by suggesting the preferred alternative.
85
85
@@ -110,13 +110,13 @@ If you'd like to learn more about the tidyverse lifecycle, I recommend the follo
110
110
111
111
The [**reprex**](https://reprex.tidyverse.org/) package helps users create **repr**oducible **ex**amples for posting to GitHub issues, StackOverflow, in Slack messages or snippets, or even to paste into PowerPoint or Keynote slides by placing the code to be shared in your clipboard. I find reprex very useful when teaching because it helps my students provide me with broken code in a way that makes it as easy as possible for me (and for other students in the class) to help them.
112
112
113
-
There has been [many](https://reprex.tidyverse.org/news/index.html#reprex-1-0-0-2021-01-27)[exciting](https://reprex.tidyverse.org/news/index.html#reprex-2-0-0-2021-04-02) developments in reprex over the year. The one that is perhaps most relevant to teaching are improvements that make it easier to use reprex when working in [RStudio Server](https://www.rstudio.com/products/rstudio/#rstudio-server) and [RStudio Cloud](https://rstudio.cloud/) as well as those that allow using local data when creating a reprex.
113
+
There have been [many](https://reprex.tidyverse.org/news/index.html#reprex-1-0-0-2021-01-27)[exciting](https://reprex.tidyverse.org/news/index.html#reprex-2-0-0-2021-04-02) developments in reprex over the year. The one that is perhaps most relevant to teaching are improvements that make it easier to use reprex when working in [RStudio Server](https://www.rstudio.com/products/rstudio/#rstudio-server) and [RStudio Cloud](https://rstudio.cloud/) as well as those that allow using local data when creating a reprex.
114
114
115
-
Many courses teache R using RStudio Server or RStudio Cloud since this approach circumvents the need for students to install software and allows the instructor to have full control over the R environment their students are learning in. When working in these environments, the R code is running in a web browser and for security reasons it's not possible for reprex to place code on your system clipboard. When creating a reprex in these environments, you can now simply select the relevant code, and run `reprex()`. This will create a `.md` file containing the contents of the reprex, ready for you to copy via Cmd/Ctrl+C.
115
+
Many courses teach R using RStudio Server or RStudio Cloud since this approach circumvents the need for students to install software and allows the instructor to have full control over the R environment their students are learning in. When working in these environments, the R code is running in a web browser and for security reasons it's not possible for reprex to place code on your system clipboard. When creating a reprex in these environments, you can now simply select the relevant code, and run `reprex()`. This will create a `.md` file containing the contents of the reprex, ready for you to copy via Cmd/Ctrl+C.
116
116
117
117
<imgsrc="reprex-cloud.png"alt="On the left: RStudio Cloud window with an R script with two lines of code highlighted. On the right: Result after running reprex() in the Console, including a new markdown file with the name vivid-eider_reprex.md that includes the code and the resulting output, commented out, and selected, ready to be copy pasted elsewhere. The viewer pane on the bottom right shows the stylized result of the reprex."width="1000"/>
118
118
119
-
Another development that will help students, particularly those working on an assignment involving a local data file, create reprexes is the new `wd` argument to set working directory of the reprex.[^2] Writing a reproducible example with a minimal dataset is better practice, but this can be quite difficult for new learners. Being able to easily use local data will make it easier for them to benefit from other aspects of reprex earlier on.
119
+
The new `wd` argument can help students create reprexes when they are working on an assignment involving a local data file. When `reprex(wd = ".")`, the reprex will be executed in the current working directory.[^2] Writing a reproducible example with a minimal dataset is better practice, but this can be quite difficult for new learners. Being able to easily use local data will make it easier for them to benefit from other aspects of reprex earlier on.
120
120
121
121
Being able to create a reprex in the current working directory means you can also benefit from a project-level `.Rprofile` if you happen to have one in your project. This is likely not going to have implications for new learners, for whom this would be an advanced concept, but it can be helpful for instructors who teach with a different suite of packages than what they locally have installed (e.g., CRAN versions for teaching vs. development versions for personal use). If this describes you, I recommend using [**renv**](https://rstudio.github.io/renv/index.html) in projects where you keep teaching materials, which uses `.Rprofile` to implement a project-specific package library. Then, `reprex(wd = ".")` will create a reprex using the packages in that library.
122
122
@@ -472,7 +472,7 @@ dtplyr translates dplyr pipelines into equivalent data.table code. To start, we
472
472
473
473
</div>
474
474
475
-
With recent updates, dtplyr can also translate some tidyr functions to data.table, e.g., [`pivot_wider()`](https://tidyr.tidyverse.org/reference/pivot_wider.html). In the following example the process is the same: start with [`lazy_dt()`](https://rdrr.io/pkg/dtplyr/man/lazy_dt.html), write a data transformation step using tidyverse code, view the resut with [`as_tibble()`](https://tibble.tidyverse.org/reference/as_tibble.html), and view the query with [`show_query()`](https://dplyr.tidyverse.org/reference/explain.html).
475
+
With recent updates, dtplyr can also translate some tidyr functions to data.table, e.g., [`pivot_wider()`](https://tidyr.tidyverse.org/reference/pivot_wider.html). In the following example the process is the same: start with [`lazy_dt()`](https://rdrr.io/pkg/dtplyr/man/lazy_dt.html), write a data transformation step using tidyverse code, view the result with [`as_tibble()`](https://tibble.tidyverse.org/reference/as_tibble.html), and view the query with [`show_query()`](https://dplyr.tidyverse.org/reference/explain.html).
0 commit comments