I have a large dataset that I would prefer not to split up because it will be rather time consuming. One column contains a list of parks which I want to make separate plots for as each plot belongs somewhere different. Each park needs to be grouped by Zone and Year as time series graphs. The mean for Height_mm also needs to be calculated with standard errors. There are 5 different parks each with 3 different zones and 10 different years. There are over 5000 records in the csv.
head(data)
Park_name Zone Year Height_mm
1 Park1 Zone1 2011 380
2 Park1 Zone1 2011 510
3 Park1 Zone1 2011 270
4 Park1 Zone2 2011 270
5 Park1 Zone2 2011 230
6 Park1 Zone2 2011 330
I would like to be able to manipulate the code below to make this work though I just can't figure it out. I'll gladly take any other suggestions though.
library(ggplot2)
library(plyr)
data=read.table("C:/data.csv", sep=",", header=TRUE)
ggplot(data, aes(x=Year, y=Height_mm)) +
#geom_errorbar(aes(ymin=mean-se, ymax=mean+se), width=.05, colour="black", position=pd) +
geom_line() +
geom_point(size=3, fill="black") +
xlab("Year") +
ylab("Mean height (mm)") +
#facet_wrap(~Park_name, scales = "free", ncol=2) + #I'd like something like this but with all plots as separate figures
theme_bw() +
theme(axis.text.x=theme_text(),
#axis.title.x=theme_blank(),
#axis.title.y=theme_blank(),
axis.line=theme_segment(colour="black"),
panel.grid.minor = theme_blank(),
panel.grid.major = theme_blank(),
panel.border=theme_blank(),
panel.background=theme_blank(),
legend.justification=c(10,10), legend.position=c(10,10),
legend.title = theme_text(),
legend.key = theme_blank()
)
I'm assuming I need a 'for' loop of some kind though I don't know where to put it or how to use it. Thanks
aggregate,split,byortapplyto chop up data?pyour original plot, you can dod_ply(Y, "Park_name", "%+%", e1=p).