I have a data frame with several columns, one of which is a factor called \"site\". How can I split the data frame into blocks of rows each with a unique value of \"site\",
Another choice is use the ddply
function from the ggplot2
library. But you mention you mostly want to do a plot of peak vs. year, so you could also just use qplot
:
A <- read.table("example.txt",header=TRUE)
library(ggplot2)
qplot(peak,year,data=A,colour=site,geom="line",group=site)
ggsave("peak-year-comparison.png")
On the other hand, I do like David Smith's solution that allows the applying of the function to be run across several processors.