hipsteR re-educating people who learned R before it was cool
I was an early adopter of R, having first
learned S (yay!) and then S-plus (yuck!). But at times my knowledge of
R seems stuck in 2001. I keep finding out about “new” R
replicate, which was new in 2003).
This is a tutorial for people like me, or people who were taught by people like me.
Switch to knitr
A number of Sweave annoyances have been eliminated, but most importantly you can use knitr with R Markdown or with AsciiDoc for writing simple reports. The markup is much simpler than LaTeX, and you don’t have to worry about page breaks.
Learn Hadley Wickham’s packages
If you’re still using the R GUI (for Windows or Mac), you should switch to RStudio. Everything about it is better.
But I use RStudio for teaching: for demonstrations, and I have the students use it; it’s the best environment for learning R.
CRAN is huge, and there’s also GitHub
And there are even more packages that live on GitHub (solely, or in
addition to CRAN), and with the
install_github() function in the
devtools package, you can skip
CRAN and install packages straight from GitHub. devtools also has an
install_bitbucket() for installing from
I’d better mention Bioconductor; oodles of bioinformatics/genomics-related packages live there rather than CRAN.
You can put underscores in names
It used to be that
_ was a shortcut for
<-. (That was always a bad
idea. And it led me to use dots in function names, like
which has been problematic due to the S3 class system.)
Then they started allowing
= in place of
And then they got rid of
_ as a shortcut for
<-. Good idea, and
now we can have functions named like
Read about new features
Read about new features in R here.
New apply-type functions
You probably know about
did you know about
mapply? And how about
Parallel and Rcpp
I searched through the
NEWS files (mentioned above) and
wrote down some of the functions that were new since 2002.
(Note that I have little experience with many of these, and some are
not entirely recommended. For example,
left_join in dplyr can be 10×
merge. Ben Bolker recommends the
replicate, as you get to define the return structure.)
The source for this tutorial is on github.
I would be glad for suggestions, corrections, or additions.