Rcode snippets
Add legend in plot
legend(c("bottomright"),legend=c("Group1","Group2","Group3"),lwd=c(2.5,2.5),col=c("red","green","blue"))
What colors are there?
http://www.stat.columbia.edu/~tzheng/files/Rcolor.pdf
Sort data frame by some column or row
sorting examples using the mtcars dataset
attach(mtcars)
sort by mpg
newdata <- mtcars[order(mpg),]
sort by mpg and cyl
newdata <- mtcars[order(mpg, cyl),]
sort by mpg (ascending) and cyl (descending)
newdata <- mtcars[order(mpg, -cyl),]
detach(mtcars)