From 6449205bf348d2ea6fdd29027a3b3774d07b8439 Mon Sep 17 00:00:00 2001 From: carriewright11 Date: Sun, 29 Sep 2024 21:10:17 -0400 Subject: [PATCH 01/13] updating rstudio lecture --- modules/RStudio/RStudio.Rmd | 56 ++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/modules/RStudio/RStudio.Rmd b/modules/RStudio/RStudio.Rmd index 688d66dd..a314bdd0 100644 --- a/modules/RStudio/RStudio.Rmd +++ b/modules/RStudio/RStudio.Rmd @@ -316,19 +316,6 @@ You can run all chunks above a specific chunk using this button: knitr::include_graphics("images/previous_chunks.png") ``` -## Chunk settings - -```{r echo=FALSE, fig.align='center', out.width="80%"} -knitr::include_graphics("images/chunk_settings.png") -``` - -## Chunk settings - -You can specify if a chunk will be seen in the report or not. - -```{r echo=FALSE, fig.align='center', out.width="80%"} -knitr::include_graphics("images/chunk_settings2.png") -``` ## Errors @@ -339,19 +326,6 @@ Note that sometimes the error occurs earlier than RStudio thinks. knitr::include_graphics("images/errors.png") ``` -## Rainbow Parentheses - -Tools --> Global Options --> Code --> Display --> Use rainbow parentheses - -Press enter to save this setting and get out of this menu. - -
-
- -```{r echo=FALSE, fig.align='center', out.width="80%"} -knitr::include_graphics("https://posit.co/wp-content/themes/Posit/public/markdown-blogs/rstudio-1-4-preview-rainbow-parentheses/colorfulCode.png") -``` - ## Useful R Studio Shortcuts @@ -442,7 +416,37 @@ Image by Global Options --> Code --> Display --> Use rainbow parentheses + +This can help you see your code more easily. + +Press enter to save this setting and get out of this menu. + +
+
+ +```{r echo=FALSE, fig.align='center', out.width="80%"} +knitr::include_graphics("https://posit.co/wp-content/themes/Posit/public/markdown-blogs/rstudio-1-4-preview-rainbow-parentheses/colorfulCode.png") +``` + + From 7e129ef52a67e79addbd744bb6a38ef0fcc897d0 Mon Sep 17 00:00:00 2001 From: carriewright11 Date: Sun, 29 Sep 2024 21:20:43 -0400 Subject: [PATCH 02/13] making directions more clear --- modules/RStudio/lab/RStudio_Lab.Rmd | 7 +------ modules/RStudio/lab/RStudio_Lab_Key.Rmd | 28 ++++++------------------- 2 files changed, 7 insertions(+), 28 deletions(-) diff --git a/modules/RStudio/lab/RStudio_Lab.Rmd b/modules/RStudio/lab/RStudio_Lab.Rmd index 295dce2f..9604d9f3 100644 --- a/modules/RStudio/lab/RStudio_Lab.Rmd +++ b/modules/RStudio/lab/RStudio_Lab.Rmd @@ -45,9 +45,7 @@ ggplot(aes(x = year, y = rate, colour = county, group = county), data = er_3) + scale_colour_manual(values = palette) ``` -```{r out.width = "100%", label = '0response'} -``` # Exercise @@ -70,10 +68,7 @@ x <- c(1, 2, 3) # Practice on Your Own! -### P.1 - -Update the options of the R chunk you just made (with the lowercase x in it) so that the output option is `show output only`. How does the chunk look now? -### P.2 +### P.1 Create another R Markdown Document from RStudio dropdowns: File → New File → R Markdown. diff --git a/modules/RStudio/lab/RStudio_Lab_Key.Rmd b/modules/RStudio/lab/RStudio_Lab_Key.Rmd index 90b3cb6a..9bf12305 100644 --- a/modules/RStudio/lab/RStudio_Lab_Key.Rmd +++ b/modules/RStudio/lab/RStudio_Lab_Key.Rmd @@ -28,24 +28,8 @@ When you click the **Knit** button (at the top of RStudio), a document will be g Here is code that will make a plot of some data.You can embed an R code chunk like this: Try pressing the green play button to see what happens. Make sure you have run the previous code chunk first by pressing the green play button in that chunk. -```{r plot, out.width = "100%"} -# keep only some counties -er_3 <- er_2 %>% - filter(county %in% c("Arapahoe", "Denver", "Jefferson", "Larimer")) - -palette <- c( - Arapahoe = "blue", - Denver = "darkgreen", - Jefferson = "orange", - Larimer = "purple" -) - -ggplot(aes(x = year, y = rate, colour = county, group = county), data = er_3) + - geom_line() + - scale_colour_manual(values = palette) -``` -```{r out.width = "100%", label = '0response'} +```{r out.width = "100%"} # keep only some counties er_3 <- er_2 %>% filter(county %in% c("Arapahoe", "Denver", "Jefferson", "Larimer")) @@ -73,7 +57,7 @@ Go through the code for the plot above and change the colors in `palette` to som ### 1.2 -Add a new R chunk after ``. You can use the insert chunk button or copy paste an existing code chunk. Include a lowercase x inside the chunk as the code. Make sure you press the knit button after this to see what the new chunk looks like. +Add a new R chunk after ``. You can use the insert chunk button or copy paste an existing code chunk. Include a lowercase x inside the chunk as the code. Make sure you press the knit button after this to see what the new chunk looks like. ```{r} x <- c(1, 2, 3) @@ -81,12 +65,12 @@ x <- c(1, 2, 3) +```{r} +x +``` + # Practice on Your Own! ### P.1 -Update the options of the R chunk you just made (with the lowercase x in it) so that the output option is `show output only`. How does the chunk look now? - -### P.2 - Create another R Markdown Document from RStudio dropdowns: File → New File → R Markdown. From 4fbbfaaa770f707f4f20f095c960687af3324a81 Mon Sep 17 00:00:00 2001 From: carriewright11 Date: Sun, 29 Sep 2024 21:28:26 -0400 Subject: [PATCH 03/13] adding stuff like sisbid lab --- modules/RStudio/lab/RStudio_Lab_Key.Rmd | 27 +++++++++++++++---------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/modules/RStudio/lab/RStudio_Lab_Key.Rmd b/modules/RStudio/lab/RStudio_Lab_Key.Rmd index 9bf12305..c6cba0b4 100644 --- a/modules/RStudio/lab/RStudio_Lab_Key.Rmd +++ b/modules/RStudio/lab/RStudio_Lab_Key.Rmd @@ -9,10 +9,14 @@ editor_options: Please read through everything and then try the exercises. This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see . The way you can create a file like this in RStudio is: File → New File → R Markdown and then using the default or using a template. +1.Try compiling this document using the “Knit HTML” button. What files are produced? + ### The Code The gray area below is a code chunk that will set up our packages and data. You can also run the code within the editor area by pressing the green play button. Don't worry right now about what the code is doing, we will cover this later. We just want you to get used to RStudio and RMarkdowns. This dataset is one we'll be working with quite a lot in the lectures. It contains county-level data about ER visits for heat-related illnesses in Colorado for the years 2011-2022. +2. Press the green play button. What happens? + ```{r setup, message=FALSE} library(tidyverse) @@ -28,6 +32,9 @@ When you click the **Knit** button (at the top of RStudio), a document will be g Here is code that will make a plot of some data.You can embed an R code chunk like this: Try pressing the green play button to see what happens. Make sure you have run the previous code chunk first by pressing the green play button in that chunk. +3. Try the play all previous button that is to the left of the play button on the following chunk. What happens? + +4. Then press the play button. What happens? ```{r out.width = "100%"} # keep only some counties @@ -46,18 +53,9 @@ ggplot(aes(x = year, y = rate, colour = county, group = county), data = er_3) + scale_colour_manual(values = palette) ``` +### Adding new chunks -# Exercise - -Here are a few changes that will show you how to change small things in `R` code and the output it makes. After each change, hit the **Knit** button again. - -### 1.1 - -Go through the code for the plot above and change the colors in `palette` to something other than what they originally were. See http://www.stat.columbia.edu/~tzheng/files/Rcolor.pdf for a large list of colors. For example, you could replace blue with red. - -### 1.2 - -Add a new R chunk after ``. You can use the insert chunk button or copy paste an existing code chunk. Include a lowercase x inside the chunk as the code. Make sure you press the knit button after this to see what the new chunk looks like. +5. Add a new R chunk after ``. You can use the insert chunk button or copy paste an existing code chunk. Include a lowercase x inside the chunk as the code. Make sure you press the knit button after this to see what the new chunk looks like. ```{r} x <- c(1, 2, 3) @@ -69,8 +67,15 @@ x <- c(1, 2, 3) x ``` + # Practice on Your Own! +Here are a few changes that will show you how to change small things in `R` code and the output it makes. After each change, hit the **Knit** button again. + ### P.1 +Go through the code for the plot above and change the colors in `palette` to something other than what they originally were. See http://www.stat.columbia.edu/~tzheng/files/Rcolor.pdf for a large list of colors. For example, you could replace blue with red. + +### P.2 + Create another R Markdown Document from RStudio dropdowns: File → New File → R Markdown. From 715ea77ea4b8fa7769edc940c68baf8abe211ef0 Mon Sep 17 00:00:00 2001 From: carriewright11 Date: Sun, 29 Sep 2024 21:42:09 -0400 Subject: [PATCH 04/13] removing automatic lab render from key for rstudio lab --- scripts/blank_labs_from_keys.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/blank_labs_from_keys.sh b/scripts/blank_labs_from_keys.sh index 660652d4..80b0c65d 100644 --- a/scripts/blank_labs_from_keys.sh +++ b/scripts/blank_labs_from_keys.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -find modules/ -type f -name "*_Key.Rmd" -print0 | while IFS= read -r -d '' file; do +find modules/ -type f ! -name "*RStudio*" -name "*_Key.Rmd" -print0 | while IFS= read -r -d '' file; do # Remove Rmarkdown chunk content # !! Note that the chunks must be named, with the name ending with "response" # to be cleared. This prevents unwanted erasure of library loading and knitr From 62956600e60c4480d42a9d60b16fb97577ccf1c0 Mon Sep 17 00:00:00 2001 From: carriewright11 Date: Sun, 29 Sep 2024 21:48:40 -0400 Subject: [PATCH 05/13] adding the labs for RStudio to be more like sisbid --- modules/RStudio/lab/RStudio_Lab.Rmd | 38 +++++++++++++++---------- modules/RStudio/lab/RStudio_Lab_Key.Rmd | 12 ++++++-- 2 files changed, 32 insertions(+), 18 deletions(-) diff --git a/modules/RStudio/lab/RStudio_Lab.Rmd b/modules/RStudio/lab/RStudio_Lab.Rmd index 9604d9f3..7ee49ada 100644 --- a/modules/RStudio/lab/RStudio_Lab.Rmd +++ b/modules/RStudio/lab/RStudio_Lab.Rmd @@ -9,10 +9,14 @@ editor_options: Please read through everything and then try the exercises. This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see . The way you can create a file like this in RStudio is: File → New File → R Markdown and then using the default or using a template. +1. Try compiling this document using the “Knit HTML” button. What files are produced? + ### The Code The gray area below is a code chunk that will set up our packages and data. You can also run the code within the editor area by pressing the green play button. Don't worry right now about what the code is doing, we will cover this later. We just want you to get used to RStudio and RMarkdowns. This dataset is one we'll be working with quite a lot in the lectures. It contains county-level data about ER visits for heat-related illnesses in Colorado for the years 2011-2022. +2. Press the green play button. What happens? + ```{r setup, message=FALSE} library(tidyverse) @@ -28,7 +32,11 @@ When you click the **Knit** button (at the top of RStudio), a document will be g Here is code that will make a plot of some data.You can embed an R code chunk like this: Try pressing the green play button to see what happens. Make sure you have run the previous code chunk first by pressing the green play button in that chunk. -```{r plot, out.width = "100%"} +3. Try the "run all chunks above" button that is to the left of the play button on the following chunk. What happens? + +4. Then press the play button on this same chunk. What happens? + +```{r out.width = "100%"} # keep only some counties er_3 <- er_2 %>% filter(county %in% c("Arapahoe", "Denver", "Jefferson", "Larimer")) @@ -37,7 +45,7 @@ palette <- c( Arapahoe = "blue", Denver = "darkgreen", Jefferson = "orange", - Larimer = "purple" + Larimer = "salmon" ) ggplot(aes(x = year, y = rate, colour = county, group = county), data = er_3) + @@ -45,20 +53,9 @@ ggplot(aes(x = year, y = rate, colour = county, group = county), data = er_3) + scale_colour_manual(values = palette) ``` +### Adding new chunks - - -# Exercise - -Here are a few changes that will show you how to change small things in `R` code and the output it makes. After each change, hit the **Knit** button again. - -### 1.1 - -Go through the code for the plot above and change the colors in `palette` to something other than what they originally were. See http://www.stat.columbia.edu/~tzheng/files/Rcolor.pdf for a large list of colors. For example, you could replace blue with red. - -### 1.2 - -Add a new R chunk after ``. You can use the insert chunk button or copy paste an existing code chunk. Include a lowercase x inside the chunk as the code. Make sure you press the knit button after this to see what the new chunk looks like. +5. Add a new R chunk after ``. You can use the insert chunk button or copy paste an existing code chunk. Include a lowercase x inside the chunk as the code. Make sure you press the knit button after this to see what the new chunk looks like. ```{r} x <- c(1, 2, 3) @@ -66,9 +63,20 @@ x <- c(1, 2, 3) + + # Practice on Your Own! +Here are a few changes that will show you how to change small things in `R` code and the output it makes. After each change, hit the **Knit** button again. ### P.1 +Go through the code for the plot above and change the colors in `palette` to something other than what they originally were. See http://www.stat.columbia.edu/~tzheng/files/Rcolor.pdf for a large list of colors. For example, you could replace blue with red. + +### P.2 + Create another R Markdown Document from RStudio dropdowns: File → New File → R Markdown. + +### P.3 + +Add a new header with two hash symbols `##` at the start of a line with some text. Knit the report to see how it looks. diff --git a/modules/RStudio/lab/RStudio_Lab_Key.Rmd b/modules/RStudio/lab/RStudio_Lab_Key.Rmd index c6cba0b4..79ee8f3d 100644 --- a/modules/RStudio/lab/RStudio_Lab_Key.Rmd +++ b/modules/RStudio/lab/RStudio_Lab_Key.Rmd @@ -9,7 +9,7 @@ editor_options: Please read through everything and then try the exercises. This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see . The way you can create a file like this in RStudio is: File → New File → R Markdown and then using the default or using a template. -1.Try compiling this document using the “Knit HTML” button. What files are produced? +1. Try compiling this document using the “Knit HTML” button. What files are produced? ### The Code @@ -32,9 +32,9 @@ When you click the **Knit** button (at the top of RStudio), a document will be g Here is code that will make a plot of some data.You can embed an R code chunk like this: Try pressing the green play button to see what happens. Make sure you have run the previous code chunk first by pressing the green play button in that chunk. -3. Try the play all previous button that is to the left of the play button on the following chunk. What happens? +3. Try the "run all chunks above" button that is to the left of the play button on the following chunk. What happens? -4. Then press the play button. What happens? +4. Then press the play button on this same chunk. What happens? ```{r out.width = "100%"} # keep only some counties @@ -79,3 +79,9 @@ Go through the code for the plot above and change the colors in `palette` to som ### P.2 Create another R Markdown Document from RStudio dropdowns: File → New File → R Markdown. + +### P.3 + +Add a new header with two hash symbols `##` at the start of a line with some text. Knit the report to see how it looks. + +## New Header From 19988b579392be80faf6b6926ae00d1150762e95 Mon Sep 17 00:00:00 2001 From: carriewright11 Date: Sun, 29 Sep 2024 21:55:24 -0400 Subject: [PATCH 06/13] making it so that the lab makes sense after the basic R lab --- modules/RStudio/lab/RStudio_Lab.Rmd | 4 ++-- modules/RStudio/lab/RStudio_Lab_Key.Rmd | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/RStudio/lab/RStudio_Lab.Rmd b/modules/RStudio/lab/RStudio_Lab.Rmd index 7ee49ada..3656ebdf 100644 --- a/modules/RStudio/lab/RStudio_Lab.Rmd +++ b/modules/RStudio/lab/RStudio_Lab.Rmd @@ -7,7 +7,7 @@ editor_options: # R Markdown -Please read through everything and then try the exercises. This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see . The way you can create a file like this in RStudio is: File → New File → R Markdown and then using the default or using a template. +The file you are reading is called an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see . The way you can create a file like this in RStudio is: File → New File → R Markdown and then using the default or using a template. 1. Try compiling this document using the “Knit HTML” button. What files are produced? @@ -15,7 +15,7 @@ Please read through everything and then try the exercises. This is an R Markdown The gray area below is a code chunk that will set up our packages and data. You can also run the code within the editor area by pressing the green play button. Don't worry right now about what the code is doing, we will cover this later. We just want you to get used to RStudio and RMarkdowns. This dataset is one we'll be working with quite a lot in the lectures. It contains county-level data about ER visits for heat-related illnesses in Colorado for the years 2011-2022. -2. Press the green play button. What happens? +2. Press the green play button. What happens (check the enviornment too!)? ```{r setup, message=FALSE} library(tidyverse) diff --git a/modules/RStudio/lab/RStudio_Lab_Key.Rmd b/modules/RStudio/lab/RStudio_Lab_Key.Rmd index 79ee8f3d..754ab895 100644 --- a/modules/RStudio/lab/RStudio_Lab_Key.Rmd +++ b/modules/RStudio/lab/RStudio_Lab_Key.Rmd @@ -7,7 +7,7 @@ editor_options: # R Markdown -Please read through everything and then try the exercises. This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see . The way you can create a file like this in RStudio is: File → New File → R Markdown and then using the default or using a template. +The file you are reading is called an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see . The way you can create a file like this in RStudio is: File → New File → R Markdown and then using the default or using a template. 1. Try compiling this document using the “Knit HTML” button. What files are produced? @@ -15,7 +15,7 @@ Please read through everything and then try the exercises. This is an R Markdown The gray area below is a code chunk that will set up our packages and data. You can also run the code within the editor area by pressing the green play button. Don't worry right now about what the code is doing, we will cover this later. We just want you to get used to RStudio and RMarkdowns. This dataset is one we'll be working with quite a lot in the lectures. It contains county-level data about ER visits for heat-related illnesses in Colorado for the years 2011-2022. -2. Press the green play button. What happens? +2. Press the green play button. What happens (check the enviornment too!)? ```{r setup, message=FALSE} library(tidyverse) From 2a37db1ed43e7d09ef159d0e90aaafe6ab8608e9 Mon Sep 17 00:00:00 2001 From: carriewright11 Date: Sun, 29 Sep 2024 21:59:22 -0400 Subject: [PATCH 07/13] fixing spelling --- modules/RStudio/lab/RStudio_Lab.Rmd | 2 +- modules/RStudio/lab/RStudio_Lab_Key.Rmd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/RStudio/lab/RStudio_Lab.Rmd b/modules/RStudio/lab/RStudio_Lab.Rmd index 3656ebdf..8b31eda4 100644 --- a/modules/RStudio/lab/RStudio_Lab.Rmd +++ b/modules/RStudio/lab/RStudio_Lab.Rmd @@ -15,7 +15,7 @@ The file you are reading is called an R Markdown document. Markdown is a simple The gray area below is a code chunk that will set up our packages and data. You can also run the code within the editor area by pressing the green play button. Don't worry right now about what the code is doing, we will cover this later. We just want you to get used to RStudio and RMarkdowns. This dataset is one we'll be working with quite a lot in the lectures. It contains county-level data about ER visits for heat-related illnesses in Colorado for the years 2011-2022. -2. Press the green play button. What happens (check the enviornment too!)? +2. Press the green play button. What happens (check the environment too!)? ```{r setup, message=FALSE} library(tidyverse) diff --git a/modules/RStudio/lab/RStudio_Lab_Key.Rmd b/modules/RStudio/lab/RStudio_Lab_Key.Rmd index 754ab895..55fdd7cf 100644 --- a/modules/RStudio/lab/RStudio_Lab_Key.Rmd +++ b/modules/RStudio/lab/RStudio_Lab_Key.Rmd @@ -15,7 +15,7 @@ The file you are reading is called an R Markdown document. Markdown is a simple The gray area below is a code chunk that will set up our packages and data. You can also run the code within the editor area by pressing the green play button. Don't worry right now about what the code is doing, we will cover this later. We just want you to get used to RStudio and RMarkdowns. This dataset is one we'll be working with quite a lot in the lectures. It contains county-level data about ER visits for heat-related illnesses in Colorado for the years 2011-2022. -2. Press the green play button. What happens (check the enviornment too!)? +2. Press the green play button. What happens (check the environment too!)? ```{r setup, message=FALSE} library(tidyverse) From f8b431344bb6f315197e878ead8093c3f469ae20 Mon Sep 17 00:00:00 2001 From: carriewright11 Date: Sun, 29 Sep 2024 22:17:37 -0400 Subject: [PATCH 08/13] adding more to the lecture, showing some of the code that was accidentally hidden with the settings for the full rmd --- modules/Reproducibility/Reproducibility.Rmd | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/modules/Reproducibility/Reproducibility.Rmd b/modules/Reproducibility/Reproducibility.Rmd index 76809906..f4200279 100644 --- a/modules/Reproducibility/Reproducibility.Rmd +++ b/modules/Reproducibility/Reproducibility.Rmd @@ -136,13 +136,19 @@ Provide sufficient detail so that you can understand what you did. ## Need random numbers to stay consistent? -Use `set.seed()` : sets the starting state for the random number generator (RNG) in R. +Use `set.seed()` : sets the starting state for the [random number generator (RNG)](https://en.wikipedia.org/wiki/Random_number_generation) in R. -```{r} -set.seed(100) +```{r, echo = TRUE} +set.seed(123) +sample(10) +set.seed(123) +sample(10) +set.seed(456) sample(10) ``` +Note that these are only psuedo random and the values are created doing calculations based on the given seed. Thus the same "random" values will be reproduced by everyone using the same seed with `set.seed`. + ## R Markdown syntax Before: @@ -176,7 +182,7 @@ ottrpal::include_slide("https://docs.google.com/presentation/d/1-cauITbscmnDEDt5 ## Session info can help -```{r, eval = FALSE} +```{r, eval = FALSE, echo = TRUE} sessionInfo() ``` From a59b4d5840eaab2a18fc80bf817dfee631c87666 Mon Sep 17 00:00:00 2001 From: carriewright11 Date: Sun, 29 Sep 2024 22:36:21 -0400 Subject: [PATCH 09/13] simplifying the lab instructions a tad to emphasize the difference between running a chunk and knitting --- modules/RStudio/lab/RStudio_Lab.Rmd | 4 ++-- modules/RStudio/lab/RStudio_Lab_Key.Rmd | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/RStudio/lab/RStudio_Lab.Rmd b/modules/RStudio/lab/RStudio_Lab.Rmd index 8b31eda4..6303e85f 100644 --- a/modules/RStudio/lab/RStudio_Lab.Rmd +++ b/modules/RStudio/lab/RStudio_Lab.Rmd @@ -26,11 +26,11 @@ er_2 <- er %>% filter(!is.na(rate)) ``` -When you click the **Knit** button (at the top of RStudio), a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. Next we will show you some code - no worries about understanding it yet, we just want to get you familiar with where code goes. When code is in an RMarkdown file chunk, it is saved to a file. When it is in the console, it is not saved. The console is useful for installing packages like we just did, this is because we only need to do it once, so we don't usually need to save the code. +When you click the **Knit** button (at the top of RStudio), a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. Note that when it does this it starts from scratch - it can't use any objects you created outside of the Rmd file. ### Plotting some data -Here is code that will make a plot of some data.You can embed an R code chunk like this: Try pressing the green play button to see what happens. Make sure you have run the previous code chunk first by pressing the green play button in that chunk. +Here is code that will make a plot of some data. 3. Try the "run all chunks above" button that is to the left of the play button on the following chunk. What happens? diff --git a/modules/RStudio/lab/RStudio_Lab_Key.Rmd b/modules/RStudio/lab/RStudio_Lab_Key.Rmd index 55fdd7cf..440c570a 100644 --- a/modules/RStudio/lab/RStudio_Lab_Key.Rmd +++ b/modules/RStudio/lab/RStudio_Lab_Key.Rmd @@ -26,11 +26,11 @@ er_2 <- er %>% filter(!is.na(rate)) ``` -When you click the **Knit** button (at the top of RStudio), a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. Next we will show you some code - no worries about understanding it yet, we just want to get you familiar with where code goes. When code is in an RMarkdown file chunk, it is saved to a file. When it is in the console, it is not saved. The console is useful for installing packages like we just did, this is because we only need to do it once, so we don't usually need to save the code. +When you click the **Knit** button (at the top of RStudio), a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. Note that when it does this it starts from scratch - it can't use any objects you created outside of the Rmd file. ### Plotting some data -Here is code that will make a plot of some data.You can embed an R code chunk like this: Try pressing the green play button to see what happens. Make sure you have run the previous code chunk first by pressing the green play button in that chunk. +Here is code that will make a plot of some data. 3. Try the "run all chunks above" button that is to the left of the play button on the following chunk. What happens? From a62bcdd65e104a5b07b3480fb6a373adbfb78804 Mon Sep 17 00:00:00 2001 From: Carrie Wright <23014755+carriewright11@users.noreply.github.com> Date: Mon, 30 Sep 2024 10:56:56 -0400 Subject: [PATCH 10/13] Update modules/RStudio/lab/RStudio_Lab.Rmd --- modules/RStudio/lab/RStudio_Lab.Rmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/RStudio/lab/RStudio_Lab.Rmd b/modules/RStudio/lab/RStudio_Lab.Rmd index 6303e85f..1f54e8df 100644 --- a/modules/RStudio/lab/RStudio_Lab.Rmd +++ b/modules/RStudio/lab/RStudio_Lab.Rmd @@ -9,7 +9,7 @@ editor_options: The file you are reading is called an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see . The way you can create a file like this in RStudio is: File → New File → R Markdown and then using the default or using a template. -1. Try compiling this document using the “Knit HTML” button. What files are produced? +1. Try compiling this document using the “Knit” button. What files are produced? ### The Code From 46fd48a15c527f3e2b27492208bb947ec3bcad1c Mon Sep 17 00:00:00 2001 From: Carrie Wright <23014755+carriewright11@users.noreply.github.com> Date: Mon, 30 Sep 2024 10:59:33 -0400 Subject: [PATCH 11/13] Update modules/RStudio/lab/RStudio_Lab_Key.Rmd --- modules/RStudio/lab/RStudio_Lab_Key.Rmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/RStudio/lab/RStudio_Lab_Key.Rmd b/modules/RStudio/lab/RStudio_Lab_Key.Rmd index 440c570a..a7dc03c3 100644 --- a/modules/RStudio/lab/RStudio_Lab_Key.Rmd +++ b/modules/RStudio/lab/RStudio_Lab_Key.Rmd @@ -9,7 +9,7 @@ editor_options: The file you are reading is called an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see . The way you can create a file like this in RStudio is: File → New File → R Markdown and then using the default or using a template. -1. Try compiling this document using the “Knit HTML” button. What files are produced? +1. Try compiling this document using the “Knit” button. What files are produced? ### The Code From 670e3232d499edeed407caddce476c30533f4efe Mon Sep 17 00:00:00 2001 From: Carrie Wright <23014755+carriewright11@users.noreply.github.com> Date: Mon, 30 Sep 2024 11:04:32 -0400 Subject: [PATCH 12/13] Update modules/RStudio/lab/RStudio_Lab.Rmd --- modules/RStudio/lab/RStudio_Lab.Rmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/RStudio/lab/RStudio_Lab.Rmd b/modules/RStudio/lab/RStudio_Lab.Rmd index 1f54e8df..b83fc6a0 100644 --- a/modules/RStudio/lab/RStudio_Lab.Rmd +++ b/modules/RStudio/lab/RStudio_Lab.Rmd @@ -26,7 +26,7 @@ er_2 <- er %>% filter(!is.na(rate)) ``` -When you click the **Knit** button (at the top of RStudio), a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. Note that when it does this it starts from scratch - it can't use any objects you created outside of the Rmd file. +When you click the **Knit** button (at the top of RStudio), a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. Note that when it does this it starts from scratch - it can't use any objects you created outside of the Rmd file. Therefore it essentially has its own environment that is different from the one that you see when working interactively in RStudio. ### Plotting some data From 02ed77f2da3e84b5ee3d60fcfeb4b45362a10e23 Mon Sep 17 00:00:00 2001 From: Carrie Wright <23014755+carriewright11@users.noreply.github.com> Date: Mon, 30 Sep 2024 11:04:43 -0400 Subject: [PATCH 13/13] Update modules/RStudio/lab/RStudio_Lab_Key.Rmd --- modules/RStudio/lab/RStudio_Lab_Key.Rmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/RStudio/lab/RStudio_Lab_Key.Rmd b/modules/RStudio/lab/RStudio_Lab_Key.Rmd index a7dc03c3..f2bb88eb 100644 --- a/modules/RStudio/lab/RStudio_Lab_Key.Rmd +++ b/modules/RStudio/lab/RStudio_Lab_Key.Rmd @@ -26,7 +26,7 @@ er_2 <- er %>% filter(!is.na(rate)) ``` -When you click the **Knit** button (at the top of RStudio), a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. Note that when it does this it starts from scratch - it can't use any objects you created outside of the Rmd file. +When you click the **Knit** button (at the top of RStudio), a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. Note that when it does this it starts from scratch - it can't use any objects you created outside of the Rmd file. Therefore it essentially has its own environment that is different from the one that you see when working interactively in RStudio. ### Plotting some data