Jamie Monogan

Using R

Here are the notes for my R short course.

Installing R

  • Download the latest version of R at: http://cran.r-project.org/. At the top of the page, click on your operating system. If you use Windows, click "base" on the next screen, and then "Download R 3.1.1 for Windows" on the final screen. If you use Mac, either "R-3.1.1-snowleopard.pkg" or "R-3.1.1-mavericks.pkg" will serve your needs, depending on your operating system. Note: The number in the filename will increase as new versions are released.
  • Note: If you ever update your version of R, this is done by downloading and re-installing the newest version, as just described. The major downside of this is the loss of previously installed packages. Install_Packages_Post_Update.R is a program by Evan Parker-Stephen that installs commonly-used packages, so it can save you some time after installing R for the first time or re-installing the latest edition.

Getting Your Feet Wet

  • The notes to my short course from UNC's Odum Institute, Washington University's School of Medicine, and various courses at UGA. Some examples use human rights data in either Stata or ASCII format. My thanks to Luke Keele & Evan Parker-Stephen for sharing earlier notes that contributed heavily to this file.
  • The R website, http://www.r-project.org/, which is helpful for downloading R, installing packages, and finding help. Under "Manuals," the document entitled "An Introduction to R" is particularly useful.
  • An R cheat sheet.
  • For a more detailed introduction, John Fox's Introduction to Statistical Computing in R is excellent.
  • For continuing questions about R, R-Seek is a Google-powered search solely over websites dedicated to R.

Additional Topics

  • If you are interested in graphics in R, consider the following sources:
    • An introduction to graphics in R written by Evan Parker-Stephen.
    • Bill Jacoby's website for Blalock Lectures on statistical graphics using the "lattice" package.
    • Vincent Zoonekynd's website with a number of tips and tricks.
    • Rcolor.pdf visually displays all of the colors available in R.
  • If you are interested in maximum likelihood estimation in R, consider these sources:
    • Marco Steenbergen's notes on programming MLE in R and Stata. I personally find R more elegant on MLE, but either program can do it.
    • This example code for deriving an MLE estimator in R and for creating simple graphs, including predicted probabilities of a logit model.
    • Example code on programming MLE, using the "glm" command, and plotting model output.
  • If you have the option to submit your R code as a batch to a Linux-based computing cluster, you may find this useful if your code either requires more memory than a desktop computer or if the code runs very slowly. Bev Wilson has written a cheat sheet based on his use of the Emerald cluster at UNC. It explains the commands to use at the terminal to successfully submit your R program.