R is free software for basically doing statistics. I learned it originally back in Berkeley as a stats major, and I originally hated it because I was also a CS major and was not used to array languages. Now I really like it.
It’s a GNU project, so it’s free software that anyone can use, study, and improve. And it’s also basically the programming language used for statistics in Berkeley (at least when I was there back in 2013). I’m pretty thankful I didn’t have to deal with proprietary software to study stats; the same can’t be said for neuroscience, where most people still use MATLAB.
Links
- Homepage
- https://www.r-project.org/
- CRAN (for most packages)
- https://cran.r-project.org/
- Documentation
- https://cran.r-project.org/manuals.html
- An Introduction to R
- R-devel manuals through stat.ethz.ch
- Emacs Speaks Statistics (ESS)
- https://ess.r-project.org/
External resources
- rseek (rseek.org) is a search engine for R (basically it just limits Google search to specific domains that usually talk about R)
- Tidyverse (originally informally the “Hadleyverse” for Hadley Wickham packages)
Internal links
Cheat sheet
Sometimes I don’t use R for a while and I forget even the most basic things.
Save a plot
If you don’t want to plot it to a window:
png(filename = "whatever.png")
plot(rnorm(100), rnorm(100))
dev.off()
If you already have a window:
dev.print(png, "whatever.png", width = 480)
See this documentation for dev.print
and this page about png
(or this page for a list of graphical devices).
Nix
I use Nix with R for reproducibility and to parallelize analyses (i.e. run analyses on computers much more powerful than my decade-old laptop). My Stan page has a Nix setup (also see direnv notes).
Most packages are under the “rPackages
” attribute.
Many packages will automatically include required dependencies (though I’ve patched some that were missing).
One issue though with Stan is that it needs a compiler at run time, so you’ll need to include that in your environment.