R Packages
1. From CRAN
Install these packages from CRAN. Always check the "install dependencies" box.
1.1. Hadleyverse
Hadley Wickham has done more than just about anyone to make R more powerful, expressive, and easy to use for common data analysis tasks.
ggplot2 — Data visualization using grammar of graphics.
dplyr — Data manipulation pipelines made easy. Noticeably distinct from its spiritual predecessor plyr. dplyr and plyr conflict so don't load both at the same time.
tidyr — Data cleaning and tidying, including reshaping from wide to long (spread) and long to wide (gather) (replaces reshape/reshape2). Also has very useful functions like separate, for splitting up columns with values like 'beach_b_10' into separate columns with 'beach', 'b', and '10'.
devtools — Automate common package development workflows. Most useful for writing custom packages but also provides idiot-proof installation packages from source on github/bitbucket or arbitrary URLs via devtools::install_github etc. (see below).
stringr and lubridate — Processing strings and dates/times with less pain.
1.2. Everything else
knitr — Literate programming for R. Mix code with text (markdown or LaTeX), and knitr::knit will run the code, format the output all purdy, and generate an HTML/PDF report.
lme4 — Mixed effects modeling.
multcomp — Confidence intervals and stuff I think.
ez — Attempt at a unified interface for analyzing output of a wide range of models (lm, glm, lmer, glmer, etc.)
gsubfn — More powerful string replacement.
hexbin — Tired of your boring old square bins? Try some exciting hexbins! Now with two extra sides!
languageR — Lots of language-specific datasets and code to go along with Baayan's book, "Analyzing Linguistic Data: A practical introduction to statistics".
MCMCglmm — Does what it says on the tin: Bayesian inference via MCMC for generalized linear mixed models. Much more flexible and powerful than lme4, but with a steep learning curve.
DPpackage — Functions for Bayesian inference via simulation in nonparametric/semiparametric models (e.g. the eponymous Dirichlet Process or "DP").
A quicker way to do it is to copy and paste the following line at your R prompt:
install.packages(c("devtools","DPpackage","ggplot2","gsubfn","hexbin","languageR","lme4","MCMCglmm","multcomp","dplyr","tidyr","stringr","lubridate","knitr","ez"))
2. From github (source)
Sometimes a package isn't available (usually temporarily) as a binary for your platform. If you need to build a package from source, make sure you have the developer tools for your OS installed. For MacOS, they are available on the App Store if you have an up-to-date version of MacOS, or from the developer site (where you'll need to register for a free account first). You may also need Fortran, available via homebrew (brew install gfortran; recommended) or from the MacOS tools page on CRAN. This StackExchange answer is a good discussion of the pros and cons of various ways to install Fortran on MacOS. The last thing you'll need (for github etc.) is to install devtools.
Let's say I want to install dplyr from the github source. I google it and find that it's hosted at http://github.com/hadley/dplyr. Then, in R:
library(devtools)
devtools::install_github('hadley/dplyr')
Piece of cake.
devtools includes a whole family of functions for installing source from pretty much anywhere you might find it. If, for instance, you want to install from the source archive on CRAN (e.g., http://cran.r-project.org/src/contrib/dplyr_0.4.1.tar.gz), you can use the install_url command:
library(devtools)
devtools::install_url('http://cran.r-project.org/src/contrib/dplyr_0.4.1.tar.gz')
3. From Bioconductor
I have no idea whether this is still necessary but I'm leaving it here for posterity's sake — Dave
When you install the packages above, you may get this warning: Warning: dependencies ‘marray’, ‘affy’, ‘Biobase’, ‘Rgraphviz’, ‘’ are not available. To fix it, install the standard packages from Bioconductor by doing the following at the R prompt:
source("http://bioconductor.org/biocLite.R")
biocLite(lib='/Library/Frameworks/R.framework/Resources/library/')
adjusting lib as appropriate for your OS. The example above is for Mac OS X. For Windows use:
biocLite(lib='C:\\Program Files\\R\\R-2.11.1\\library')
adjusting the version number as appropriate. (n.b. You must have Administrator privileges to install anything under C:/Program Files/)