From 9b9f2dbeec161cc77a7702712ccceaa2d6900d0c Mon Sep 17 00:00:00 2001 From: avahoffman Date: Mon, 8 Jul 2024 12:28:13 -0400 Subject: [PATCH] Changes per Daseh --- modules/RStudio/lab/RStudio_Lab_Key.Rmd | 41 +++++++++++++------------ 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/modules/RStudio/lab/RStudio_Lab_Key.Rmd b/modules/RStudio/lab/RStudio_Lab_Key.Rmd index 3fa460e31..083e19c18 100644 --- a/modules/RStudio/lab/RStudio_Lab_Key.Rmd +++ b/modules/RStudio/lab/RStudio_Lab_Key.Rmd @@ -17,24 +17,29 @@ Now we will install some packages! Note it may take ~5-10 minutes to run all the ### 0.1 -First copy and paste the following code into the console (the lower left panel/pane) - **but do not copy the backticks**:
-`install.packages("remotes")`
+First copy and paste the following code into the console (the lower left panel/pane): +install.packages("remotes") + This code will install a package from CRAN called "remotes".
You may be asked a question in the console when you do this. If so, answer by typing Yes into the console. ### 0.2 -Next copy and paste the following code again into the console (the lower left panel/pane), **again do not copy the backticks**:
-`library(remotes)`
+Next copy and paste the following code again into the console (the lower left panel/pane): +library(remotes) + This code loads the remotes package into memory- in other words we can use the functions within the package.
You may be asked a question in the console when you do this. If so, answer by typing Yes into the console. ### 0.3 -Now install a package that the instructors made that is not on CRAN but on GitHub, by copy and pasting the code into the console. We still don't want to copy the backticks.
-`install_github("jhudsl/jhur")`
+Now install a package that the instructors made that is not on CRAN but on GitHub, by copy and pasting the code into the console: + +install_github("jhudsl/jhur") + You may be asked a question in the console when you do this. If so, answer by typing Yes into the console. +### 0.4 The gray area below is a code chunk that will set up our packages and data (this will not show up in the rendered report when we press knit). 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. @@ -62,10 +67,8 @@ The console is useful for installing packages like we just did, this is because ## Plotting some data -Here is code that will make a plot of the average daily ridership in Baltimore City for the Charm City Circulator: https://www.charmcitycirculator.com/ (again don't worry about the actually code much for now). - - -Here we plot a few days. 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. +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_circ, out.width = "100%"} # keep only some days @@ -110,23 +113,23 @@ When code is in an RMarkdown file chunk, it is saved to a file. When it is in th 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. + ## 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. -Here is another code chunk for our exercises. - -```{r} -x <- c(1, 2, 3) -``` - ### 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 below the bonus instructions.You can use the insert chunk button or copy paste an existing code chunk. Include a lowercase x inside the chunk as the code. Thus it should look like the chunk above but without `<- c(1,2,3)`. Make sure you press the knit button after this to see what the new chunk looks like. +Add a new R chunk below the following chunk. 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) +``` # Practice on Your Own! @@ -139,8 +142,6 @@ Update the options of the R chunk you just made (with the lowercase x in it) so Create another R Markdown Document from RStudio dropdowns: File → New File → R Markdown. - - -```{r echo=FALSE, label = '2response'} +```{r echo=FALSE, label = 'P.2response'} x ```