In your project, create two directories: scripts
and reports
Create a script prepare.R
in the scripts
directory
Create an RMarkdown document from template, save it as final.Rmd
in the reports
directory.
Add code to prepare.R
to transform the flights
data in some way. (Use subsetting, add new variables, or compute a summary. Anything works.) Assign the result to a global variable using <-
. Save this variable to a file using the saveRDS()
function.
Hint: Use library(here)
and here()
to control where the file is saved.
Leave only the header and the “setup” chunk in final.Rmd
. In the “setup” chunk, insert a call to the readRDS()
function for the file you saved in the previous step.
Hint: Use here
again, you should be using the same file name that you have used for saveRDS()
.
Knit the document. This should work without failure (but show an empty document).
Create a second code chunk that shows a plot of your transformed data. Do not refer to flights
. Knit again.
Choose File / New File / R Markdown… from the RStudio menu. In the dialog, select “From template” in the pane on the left-hand side and then “Ninja presentation” to create an example slide deck. Knit it.
What templates are available from the “rticles” package? Are any of them useful for your work?
Navigate to https://github.com/rstudio/bookdown-demo (or search for “bookdown demo” in a search engine). Extract the demo to a directory of your choice, and follow the instructions in the README.md
file.
Copyright © 2018 Kirill Müller. Licensed under CC BY-NC 4.0.