15:00
Day 02
Carleton College
Stat 220 - Spring 2025
day02
repo and create an R project#
to add descriptive section headers for each code chunkgithub.com
and confirm you can see your changes15:00
Oops! I gave you the wrong set of data.
Karl – this is very interesting , however you used an old version of the data (n=143 rather than n=226). I’m really sorry you did all that work on the incomplete dataset.
Bruce
Short Term Impact
Long Term Impact
Scriptability \(\rightarrow\) R
Code environment \(\rightarrow\) RStudio
Literate programming (code, narrative, output in one place) \(\rightarrow\) R Markdown
Version control \(\rightarrow\) Git / GitHub
An authoring framework for data science.
A document format (.Rmd
).
An R package named rmarkdown
.
A file format for making dynamic documents with R.
A tool for integrating prose, code, and results.
A computational document.
quarto
?```{r setup, include=FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
out.width = "100%"
)
```
setup
include=FALSE
There’s an example HTML report on the schedule
Your task is to reproduce it in 02-example-lego.rmd
(or .qmd, if you prefer).
To be as reproducible as possible, you’ll need to use:
For example, instead of typing 19798 you would include nrow(sets)
as an inline code chunk. Make sure the report knits and you get the right values.
Next, add a parameter to your YAML header that stores the location of the data set. Make sure the report knits.
Change the code chunk where you load the data set to use the data
parameter you just defined rather than the hard-coded URL. Make sure the report knits.
Now, let’s make a parameter for the source of the data set so you don’t have to search where every mention of it in the report, it will be with the other metadata (where it belongs). To do this, add a parameter that gives the source of your data (call it data_source
) and set it equal to “the 2022-09-09 repository on Tidy Tuesday.” Make sure the report knits.
At this point it looks like everything is working—awesome job! To put it to the test, let’s update the parameters of your report and knit it to see if everything changes as we would expect. Here are the new parameter values: