Skip to content
Prev 320281 / 398506 Next

Plot cumulative sums of rainfall per year

Hi
Date in your cumu is not date but factor.

Maybe it can be accomplished by ggplot but in that case I would use standard plot.

cumu$dat<-as.Date(cumu$Date)
cumu$mon<-as.Date(format(cumu$dat, paste("%d.%m", 2012, sep=".")), format="%d.%m.%Y")
lll<-split(cumu[,c(4, 6)], cumu$year)
plot(lll[[1]][[2]], lll[[1]][[1]], type="l")
lines(lll[[2]][[2]], lll[[2]][[1]], col=2)

you can use ylim to set proper range and put lines command into for cycle if necessary.

Regards
Petr