Note to self: Basic R operations
October 18, 2012
Note to self: Basic R operations # After searching for that all too often and for too long (in particular the “add a column as index” bit): To read a file: d <- read.table(’/home/isabel/input’, sep=’,’, header=T, quote=’’) Useful for getting an overview of the data:summary(d); head(d); tail(d) For sorting some data frame: s <- d[order(d[,2]),]; For adding a column to a data frame: s$idx <- seq(0, nrow(s) - 1, 1) ...