Skip to content
Prev 205256 / 398506 Next

plot question

I gather that each row defines one series, right?   In that case try this:


Lines <- "date    sober    no    vm    nm    va    na    vs
20091229    NA    6.8    NA    2.7    11.7    2.7    6.2
20091230    NA    6.8    NA    2.7    11.7    2.7    6.2
20091231    NA    6.8    NA    2.7    11.7    2.7    6.2"

# g <- read.table("myfile.txt", header = TRUE)
g <- read.table(textConnection(Lines), header = TRUE)

# create zoo object with each series in a column and plot it
# na.approx fills in NAs with interpolated values

library(zoo)

z <- zoo(t(g[, -1]))
colnames(z) <- g[,1]

plot(na.approx(z), type = "b", main = "Glucose")

If you want the series surperimposed on one panel then add the
screens=1 argument to the last line.
On Sun, Jan 3, 2010 at 3:24 PM, Albert-Jan Roskam <fomcl at yahoo.com> wrote: