[R] Plotting multivariate time-series with ggplot2
A Duranel
arnaud.duranel.09 at ucl.ac.uk
Sun Aug 11 23:05:09 CEST 2013
Hello all.
Let's say I have a multivariate time-series, obtained from 2 loggers
returning a numeric value and a factor giving additional information about
this numeric value, for instance its accuracy:
data<-data.frame(date=rep(seq(from=as.Date("2012-01-01"), by=1,
length.out=100), 2), logger=c(rep("logger1",100), rep("logger2", 100)),
value=rnorm(200), accuracy=rep(c(rep("poor", 25), rep("good", 50),
rep("poor", 25)),2))
I would like to plot this time-series using ggplot2, with one facet per
logger, and using colour to show the accuracy class:
ggplot(data, aes(date, value,
colour=accuracy))+geom_line()+facet_wrap(~logger)
<http://r.789695.n4.nabble.com/file/n4673535/Rplot.jpeg>
The problem is that ggplot2 actually plots 2 discontinuous time-series in
each facet (one for each accuracy class), which results in straight lines
across the plot, and line breaks between different accuracy classes. Of
course I could create 4 time-series with the same index, padding them with
NAs to get rid of the straight lines, but this would not get rid of the line
breaks, and, since the actual data have many more possible logger x accuracy
combinations, I was wondering if there was an easier and quicker way?
Many thanks
Arnaud
--
View this message in context: http://r.789695.n4.nabble.com/Plotting-multivariate-time-series-with-ggplot2-tp4673535.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list