Skip to content
Prev 285063 / 398503 Next

How to import time-series data

On Sun, Feb 12, 2012 at 12:35 PM, RichardSmith
<richardsmith404 at gmail.com> 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)