R language
Notes and links on R.
Meta
Why/Why not R
 “simply start over and build something better”  Xi’an’s Og; follow up by Andrew Gelman  Ross Ihaka to R: Drop Dead  Statistical Modeling, Causal Inference, and Social Science
Articles
Books and manuals
 Introduction to statistical thinking using R; without calculus. Jun 2011.
 Teach Yourself R (pdf) is a nice Q&A styled short manual.
 Learn Statistics with R (pdf) is a 500+ page book on learning stats with R from researchers at Adelide University.
 R tutorial by Prof. Kelly Black
 Practical tools for exploring data and models, PhD thesis of Hadley Wickham.
 R for Data Science (Free online book by Garrett Grolemund & Hadley Wickham)
 Cookbook for R by Winston Chang; solutions to common tasks and problems in analyzing data.
 Using R for psychological research a tutorial.
 Book recommendations discussion.
 One Page R: A Survival Guide to Data Science with R
 Graphical Data Analysis with R; via Andrew Gelman
 Impatient R; a short tutorial.
 Introduction to R by Larry Wasserman.
 Manning  Practical Data Science with R
Tools
 RStudio – user interface for R. It’s free and open source, and works on Windows, Mac, and Linux.
 Swirl – its purpose is to teach users statistics and R simultaneously and interactively.
 RKWard is nicer looking.
 R Commander is a
tcl/tk based interface.
sudo aptget install rcranrcmdr
 Interactive Documents with R see demo.
 Publish R documents (code+words)
 Knitr is an important tool for reproducible research. A brief guide
 Emacs can communicate with R using ESS.
Learning R
Classes
 Concepts in computing with data Stats 133, Spring 2011, Berkeley. R+XML+Databases. 350 page notes.
 Data Technologies for Statistical Analysis Stat585, Spring 2014, Iowa state by Dianne Cook.
Blogs
 http://www.rbloggers.com/. Aggregates R related blogs. feed
 http://rud.is/b/ – data science + infosec + R
 http://strengejacke.wordpress.com/tag/rstats/ [code]
 http://www.jameskeirstead.ca/tag/rstats/ [code, vis]
 http://www.rstatistics.com/
 http://andrewgelman.com/  Andre Gelman is a popular author of Stats books and a regular blogger on applications of stats in “civilian” life.
 24 days of R
 http://www.theanalysisfactor.com/tag/r/
 http://bayesianbiologist.com/
 Home  RWeekly.org
Packages

R packages for undergraduate stat ed [Aug 2015]

devtools to make your life as a package developer easier by providing R functions that simplify many common tasks
 sqldf is an R package for runing SQL statements on R data frames, optimized for convenience.
 ggplot2 popular graphing package; replacement for the default plotting routines.
 chloroplethr – for plotting spatial, geographical data.
 swirl – is a software package for the R statistical programming language. Its purpose is to teach users statistics and R simultaneously and interactively.
 dplyr set of tools for efficiently manipulating datasets in R. dplyr is the next iteration of plyr, focussing on only data frames.
 lubridate
 rcharts.io is an R package to create, customize and publish interactive javascript visualizations from R using a familiar lattice style plotting interface.
 sparkTable sparklines in R.
 slopegraph Tufte’s slopegraphs in R.
 RCPP provides C++ classes that greatly facilitate interfacing C or C++ code in R packages using the .Call() interface provided by R.
Code samples
 https://github.com/huebner/Rlabs – R code for undergrad statistics course
 https://github.com/timelyportfolio
 rstudio spark (google search) for Rshiny projects.
 Tale of two conferences: basketball use of RShiny
 Subsetting to clean your data
Libraries
Tech notes, papers and articles on R
 Revolution analytics white papers
Installing R and contributed libraries.
R is made of rcore and thousands of contributed libraries. To begin with, we need to install the core application.
On Linux:
$ sudo aptget install rbasecore
R and PostgreSQL
Preparing R to query data from postgresql. Reference.
Installation
$ sudo aptget install libpqdev $ sudo aptget install rbasecore $ export PG_LIB_DIR=/usr/lib/postgresql/8.4/lib/ $ export PG_INCLUDE_DIR=/usr/include/postgresql
Install R packages from the bash/zsh shell
export CRAN_MIRROR="http://cran.case.edu/" echo "install.packages(\"rjson\", repos=\"$CRAN_MIRROR\")"  R vanilla
R Session
source("http://bioconductor.org/biocLite.R") biocLite("RdbiPgSQL") library(RdbiPgSQL) conn < dbConnect(PgSQL(), host="localhost", dbname="somedb", user="pradeep", password="secret") res < dbSendQuery(conn, "SELECT a,b,c from sometable") mydata < dbGetResult(res)
R Script
To make a R file into an executable script do the following:
#!/usr/bin/env Rscript # one.R # chmod +x one.R # ./one.R y=c(12,15,28,17,18) x=c(22,39,50,25,18) mean(y) mean(x) png(filename="plot.png") plot(x,y)
Output:
[1] 18 [1] 30.8
and plot.png
written to disk.