GNU/Linux Desktop Survival Guide by Graham Williams |
|||||
Emacs, provided by the emacs21 package, with the additional ess package, provides an excellent interface for working with R. To get started within emacs, simply issue the command M-x R enter. This will ask for a starting data directory which defaults to the current working directory (if you simply press enter again).
Then try a few simple commands like the following (from the sample session appendix of the Venables and Smith Introduction to R:
R : Copyright 2004, The R Foundation for Statistical Computing Version 1.9.1 (2004-06-21), ISBN 3-900051-00-3 [...] > help.start() > x <- rnorm(50) > y <- rnorm(x) > x > y > plot(x,y) > ls() > x <- 1:20 > w <- 1 + sqrt(x) > q() |
Some tips and tricks:
> ?plot # The ? is a shortcut for help(). > ds[,5:10] # Select columns 5 to 10 from ds. > ds[,c(3,5,8,9)] # Select columns 3, 5, 8, and 9 from ds. > class(x) # Identify the type of x. > identical(x,y) # Test if data is identical. > nrow(ds) # Number of rows in the data set. > rm(list=ls(all=TRUE)) # Remove everything from the environment. > sample(2:12, 100, replace=TRUE) # 100 random samples with replacement. > summary(dataset) # Generates a summary of the dataset. |