Dear Stephen,
It is much easier to do you data preparation before plotting.
Cummul <- ddply(subset(DF, precipitation!="NA"), "gauge_name",
function(x){
x$Cummul <- cumsum(x$precipitation)
x
})
ggplot(Cummul, aes(x = date_time, y = Cummul)) + geom_line() +
facet_wrap(~gauge_name, scales="free_y")
HTH,
Thierry
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be
To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data.
~ Roger Brinner
The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of
data.
~ John Tukey
-Oorspronkelijk bericht-
Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
Namens stephen sefick
Verzonden: dinsdag 6 oktober 2009 16:07
Aan: r-help@r-project.org
Onderwerp: [R] ggplot cumsum refined question (?)
OK, so maybe last night was a little too much at one throw, so I have
reduced the data to two stations- one that has precipitation and one
that does not. This is going to be in the context of a larger data
set. I would like to be able to issue a ggplot command and have cum
sum just act on the facets (factors) to apply this.
library(chron)
library(ggplot2)
DF <- structure(list(date_time = structure(c(14522, 14522.010417,
14522.020833, 14522.03125, 14522.041667, 14522.052083,
14522.0625, 14522.072917, 14522.08, 14522.09375,
14522.104167, 14522.114583, 14522.125, 14522.135417,
14522.145833, 14522.15625, 14522.17, 14522.177083,
14522.1875, 14522.197917, 14522.208333, 14522.21875,
14522.229167, 14522.239583, 14522.25, 14522.260417,
14522.270833, 14522.28125, 14522.291667, 14522.302083,
14522.3125, 14522.322917, 14522.33, 14522.34375,
14522.354167, 14522.364583, 14522.375, 14522.385417,
14522.395833, 14522.40625, 14522.416667, 14522.427083,
14522.4375, 14522.447917, 14522.458333, 14522.46875,
14522.479167, 14522.489583, 14522.5, 14522.510417,
14522.520833, 14522.53125, 14522.541667, 14522.552083,
14522.5625, 14522.572917, 14522.58, 14522.59375,
14522.604167, 14522.614583, 14522.625, 14522.635417,
14522.645833, 14522.65625, 14522.67, 14522.677083,
14522.6875, 14522.697917, 14522.708333, 14522.71875,
14522.729167, 14522.739583, 14522.75, 14522.760417,
14522.770833, 14522.78125, 14522.791667, 14522.802083,
14522.8125, 14522.822917, 14522.83, 14522.84375,
14522.854167, 14522.864583, 14522.875, 14522.885417,
14522.895833, 14522.90625, 14522.916667, 14522.927083,
14522.9375, 14522.947917, 14522.958333, 14522.96875,
14522.979167, 14522.989583, 14523, 14523.010417,
14523.020833, 14523.03125, 14523.041667, 14523.052083,
14523.0625, 14523.072917, 14523.08, 14523.09375,
14523.104167, 14523.114583, 14523.125, 14523.135417,
14523.145833, 14523.15625, 14523.17, 14523.177083,
14523.1875, 14523.197917, 14523.208333, 14523.21875,
14523.229167, 14523.239583, 14523.25, 14523.260417,
14523.270833, 14523.28125, 14523.291667, 14523.302083,
14523.3125, 14523.322917, 14523.33, 14523.34375,
14523.354167, 14523.364583, 14523.375, 14523.385417,
14523.395833, 14523.40625, 14522, 14522.010417,
14522.020833,
14522.03125, 14522.041667, 14522.052083, 14522.0625,
14522.072917, 14522.08, 14522.09375, 14522.104167,
14522.114583, 14522.125, 14522.135417, 14522.145833,
14522.15625, 14522.17, 14522.177083, 14522.1875,
14522.197917, 14522.208333, 14522.21875, 14522.229167,
14522.239583, 14522.25, 14522.260417, 14522.270833,
14522.28125, 14522.291667, 14522.302083, 14522.3125,
14522.322917, 14522.33, 14522.34375, 14522.354167,
14522.364583, 14522.375, 14522.385417, 14522.395833,
14522.40625, 14522.416667, 14522.427083, 14522.4375,
14522.447917, 14522.458333, 14522.46875, 14522.479167,
14522.489583, 14522.5, 14522.510417, 14522.520833,
14522.53125, 14522.541667, 14522.552083, 14522.5625,
14522.572917, 14522.58, 14522.59375, 14522.604167,
14522.614583, 14522.625, 14522.635417, 14522.645833,
14522.65625, 14522.67, 14522