Statistical routines in R