[R] How to import time-series data

RichardSmith richardsmith404 at gmail.com
Mon Feb 13 14:23:09 CET 2012


Gabor Grothendieck wrote
> 
> Try this xyplot.zoo lattice graph.   Time series are represented in
> columns so we transpose the data and convert it to zoo.  The screen=
> argument available in xyplot.zoo groups series into panels:
> 
> Lines <- "plant,aphid,1,2,3,4
> pumpkin,1-2,0.065566,0.057844,0.08,0.086879
> pumpkin,1-3,0.107612,0.097272,0.11663,0.160499
> squash,1-4,0.126939,0.115003,0.140275,0.188829"
> 
> library(zoo)
> library(lattice)
> DF <- read.csv(text = Lines)
> z <- zoo(t(DF[3:6]))
> colnames(z) <- DF$aphid
> xyplot(z, screen = DF$plant)
> 

Thank you! That gets the data in exactly the shape I was expecting. I was
hoping to get the graph showing all lines on one plot, but coloured
according to plant. I tried to change screen=DF$plant for groups=DF$plant,
but it doesn't work, and I can't figure out from the documentation why it
doesn't work (I think I need to more thoroughly understand data types
first). Could you point me in the right direction?

Thanks so much for your help so far.

--
View this message in context: http://r.789695.n4.nabble.com/How-to-import-time-series-data-tp4381372p4383740.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list