ICPSR Summer Program Teaching

R - Learning By Example

The Learning by Example course will attempt to provide you everything you need to get your own analyses up and running in R. We will focus on data management and analysis (day 1), visualization (day 2), other models/programming/reproducible research (day 3). Click for a a more detailed outline

You can install the packages that we need for today with the following script (you can just copy and paste it into R:

installed.pkgs <- installed.packages()[, "Package"]
pkgs <- c("car","compute.es","DAMisc", "devtools",
  "effects","factorplot","foreign","games", "ggplot2",
  "gmodels", "lattice", "lmtest", "MASS", "multcomp",
  "multiwayvcov", "nnet", "plyr", "RColorBrewer",
  "rgdal", "rgl", "sandwich", "spdep", "tcltk",
  "vcd", "xlsx")
dups <- which(pkgs %in% installed.pkgs)
if(length(dups) > 0){pkgs <- pkgs[-dups]}
if(length(pkgs) > 0){
  for(i in 1:length(pkgs)){

1 Day 1: Data Management and Analysis

  • All code and data for handout 1 zip

For Day 2, we need to install a couple of things:

  • World shape file zip

  • Java Runtime Environment, don’t forget to click on the “Accept” radio button. Also, you’ll probably want the 64 bit version, but to make sure go into R studio and run the following command version in R. If the arch row has x86_64, then you need the 64-bit JRE, otherwise if it says i386 or has 32 in it, then you need the 32-bit JRE.

  • Install the Deducer package in R along with its dependencies after installing the Java Runtime environment.

2 Day 2: Data Visualization

3 Day 3: Programming/Repoducibility