Students
Tuition Fee
Not Available
Start Date
Not Available
Medium of studying
Not Available
Duration
Not Available
Details
Program Details
Degree
Masters
Course Language
English
Intakes
Program start dateApplication deadline
2016-02-23-
About Program

Program Overview


Programming with R for Reproducible Research

Course Synopsis

The course provides an overview of programming with R for reproducible research.


Prerequisites

  • Both parts of "Using R for Data Analysis" (lecture in fall semester), or similar knowledge of R on at least an intermediate level
    • Slides of "Using R .." (2013)
    • Slides of "Using R .." (2012) (with slightly more material in part 2)
    • The "textbook" of "Using R": Longhow Lam (2010). An Introduction to R freely available from CRAN.
  • Laptop with R (>= 3.0.1) and one of RStudio / StatET / ESS, (or similar) "R IDE" installed. Two students may team up, using one computer.
  • One semester of (introduction to) statistics

Start of Lectures

Tuesday, 23.02.2016


Lecture Material

Week 1

  • Organization, Topics, etc: Emacs org (source), pdf.
  • R code during browsing of "Using R.." chapter 7: -ex.R.
  • R markdown ("Rmd") file first.Rmd, conveniently opened in Rstudio, demonstrating both R markdown with its HTML, i.e. web content output.
  • "Everything (in R) is an object" --> explorations and a table and its Rmd source

Week 2

  • Your questions about "Using R" (and the material above)
  • && vs & and || vs |
  • coercion:
  • More on functions, notably closures: The 2 (and three) parts of a function: Commented R code and R markdown.
  • Excursion: Exploring R packages and functions in there:
  • Using the R code from Matloff's book.

Week 3

  • Our edition of original Ch7/bookvec.R
  • our example "text corpus" text1.txt
  • Our version of original Ch4/findwords.R; and the (more efficient!)
  • Our modified excerpt of H.Wickham's functional programming chapter.

Week 4

  • continuing "functional programming" (week 3, above)
  • The initial R session, somewhat extended, of How R Searches and Finds Stuff
  • Functions -> environments:
  • ls(), get(), assign(), find(), ls.str(), new.env(), parent.env(),
  • globalenv(), emptyenv(), and the first two figures in How R Searches and Finds Stuff

Week 5

  • one_counter() example in "functional programming" (above) --- please study as , ask in class.
  • "R is slow" etc:
    • "Premature optimization is the root of all evil ", Donald Knuth
    • Rather: Test, test, and test again; using all.equal(target, current, tolerance ~= 10^-8)
    • typical issue about for() loop from Stackoverflow
    • User Q about 'matrix vs. data.frame' on the R-help mailing list (March 2014).
    • Our (modified) Rmd on "Performance" from Hadley Wickham's book chapter "Performance".

Week 6

  • Continuing "Performance" (see week 5): "Measure, don't guess" --> Using Rprof() and microbenchmark
  • The 'matrix vs. data.frame' R-help example continued see above).
  • R's byte compiler (-> require("compiler"); ?cmpfun), see in the above *.Rmd
  • Performance <-> Copying of R objects: "Traching memory" memory-copying.R script.
  • Start looking at R packages, source and "binary"; at first packages and namespace: env-namespace.R

Week 7

  • R packages, in source and "binary"; browsing Notes of "Package writing" course (Rnw and R files) (and the the "one" slide from week 2)
  • package.skeleton()
  • Packages and their Namespaces: Why are namespaces needed: Rmd whyNamespaces.Rmd and its html whyNamespaces.html.
  • What happens when you call library(<pkg>) ?
  • Understand more of How R Searches and Finds Stuff: Script week7-namespace-pkg.R

Extras

  • a small script to get all methods of a generic function, nicely in a list, hidden or not.
  • from lapply() to parLapply(): R's builtin package 'require(parallel)'

Lecture Attestation (Testat)

In order to obtain the ECTS credit you have to pass the exam -- answering some questions, and writing R code - in a *.Rmd (R Markdown file) at the end of the teaching block, specifically on April 15.


Recommended Reading

  • Norman Matloff (2011) The Art of R Programming - A tour of statistical software design.
  • Hadley Wickham (2013 ff) Advanced R
  • Suraj Gupta (March 29, 2012) How R Searches and Finds Stuff

Miscellaneous on Programming (with R)

  • "Literate Programming" by Donald Knuth
  • "The Elements of Programming Style" by Kernighan and Plauger: Wikipedia,
  • Quotes
See More