From be75ba60362c49d46c4de256a560ede5370d60db Mon Sep 17 00:00:00 2001 From: carriewright11 Date: Thu, 26 Dec 2024 14:14:17 -0700 Subject: [PATCH] adding cheatsheets and gut checks --- modules/Data_Cleaning/Data_Cleaning.Rmd | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/modules/Data_Cleaning/Data_Cleaning.Rmd b/modules/Data_Cleaning/Data_Cleaning.Rmd index 2745e5d2b..d3c407416 100644 --- a/modules/Data_Cleaning/Data_Cleaning.Rmd +++ b/modules/Data_Cleaning/Data_Cleaning.Rmd @@ -618,6 +618,13 @@ data_ginger_mint %>% count(Group, Effect) ``` +## GUT CHECK: If we want all unspecified values to remain the same with `case_when()`, how should we complete the `TRUE ~` statement? + +A. With the name of the variable we are modifying or using as source + +B. With the word "same" + + # Working with strings ## Strings in R @@ -734,7 +741,7 @@ data_ginger_mint %>% count(Treatment, Treatment_recoded) ``` -This is a more robust solution! It will catch typos as long as first letter is correct or there is part of the word mint. +This is a more robust solution! It will catch typos as long as the first letter is correct or there is part of the word mint. ## That's better! @@ -742,6 +749,15 @@ This is a more robust solution! It will catch typos as long as first letter is c knitr::include_graphics("https://media1.giphy.com/media/S9ZK4mmi3u3jdc5dek/200w.webp?cid=ecf05e47h7myga959jwvek6s9x1tkog135g7pxu8vvjz2yqb&rid=200w.webp&ct=g") ``` + +## GUT CHECK: What `stringr` function helps us find a string pattern? + +A. `str_replace()` + +B. `str_find()` + +C. `str_detect()` + # Separating and uniting data ## Uniting columns @@ -806,6 +822,8 @@ knitr::include_graphics("images/case_when.png") 📃 [Day 5 Cheatsheet](https://jhudatascience.org/intro_to_r/modules/cheatsheets/Day-5.pdf) +📃 [Posit's `stringr` Cheatsheet](https://evoldyn.gitlab.io/evomics-2018/ref-sheets/R_strings.pdf) + ```{r, fig.alt="The End", out.width = "50%", echo = FALSE, fig.align='center'} knitr::include_graphics(here::here("images/the-end-g23b994289_1280.jpg")) ```