This content is from the fall 2016 version of this course. Please go here for the most recent version.
Due before class Wednesday October 26th.
Basic goal of the assignment:
.Rmd
, actually, that brings everything together. Present the original data, the statistical summaries, and/or the figures in a little report. Also build and interpret a statistical model.hw04
repositoryGo here to fork the repo for homework 04.
The easiest approach uses the example pipeline as a template for your own assignment. You can get fancier if you want (e.g. create a Bash shell script that runs the pipeline, rather than another .R
script), but you don’t have to go overboard with it.
Whatever you want! The important thing is that the entire analysis is reproducible. That is, I will clone your repository on my computer, I will run the script that “rules them all”, and it should reproduce your results and analysis without any errors.1
Okay, then analyze one of the datasets we’ve used before.
gapminder
gun_deaths
Download the raw data. For example, using gapminder
:
Option 1: via an R script using downloader::download or RCurl::getURL.
downloader::download("https://raw.githubusercontent.com/jennybc/gapminder/master/inst/gapminder.tsv")
cat(file = "gapminder.tsv",
RCurl::getURL("https://raw.githubusercontent.com/jennybc/gapminder/master/inst/gapminder.tsv"))
Option 2: in a shell script using curl
or wget
.
curl -O https://raw.githubusercontent.com/jennybc/gapminder/master/inst/gapminder.tsv
wget https://raw.githubusercontent.com/jennybc/gapminder/master/inst/gapminder.tsv
Create a figure for each continent, including data only for the 6-8 “extreme” countries, and write to file. One file per continent, with an informative name. The figure should give scatterplots of life expectancy vs. year, facetting on country, fitted line overlaid.
Identify and test a method of running your pipeline non-interactively.
You could write a master R script that simply source()
s the three scripts, one after the other. Tip: you will probably want a second “clean up / reset” script that deletes all the output your scripts leave behind, so you can easily test and refine your strategy, i.e. without repeatedly deleting stuff “by hand”. You can run the master script or the cleaning script from a shell with Rscript
.
Provide a link to a page (oh hey there README.md
) that explains how your pipeline works and links to the remaining files. Your peers and myself should be able to go to this landing page and re-run your analysis quickly and easily.
Rscript -e "rmarkdown::render('myAwesomeAnalysis.Rmd')"
rmarkdown::render('myAwesomeAnalysis.Rmd)
Your assignment should be submitted as a set of R scripts, R Markdown documents, data files, figures, etc. Follow instructions on homework workflow. As part of the pull request, you’re encouraged to reflect on what was hard/easy, problems you solved, helpful tutorials you read, etc.
Check minus: Cannot run the pipeline. Scripts require interactive coding to fix. Markdown documents are not generated. Graphs and tables don’t have appropriate labels or formatting.
Check: Solid effort. Hits all the elements. No clear mistakes. Easy to follow (both the code and the output). Nothing spectacular, either bad or good.
Check plus: Repository contains a detailed README.md
explaining how the pipeline works. Displays innovative data analysis or coding skills. Graphs and tables are well labeled. Analysis is insightful. I walk away feeling I learned something.
Okay, if I get an error because you used a package that I don’t already have, that’s my fault. But you know what I mean.↩
This work is licensed under the CC BY-NC 4.0 Creative Commons License.