On Thu, Sep 23, 2010 at 5:53 PM, Struve, Juliane <j.str...@imperial.ac.uk>wrote:
> Hello, > > thank you very much for replying. I have tried this, but I get error > message > > "Error in .subset(x, j) : invalid subscript type 'list'" after > > z1 <- read.zoo(textConnection(Lines1), skip = 1, index = list(1, 2), FUN = > dt) > > Regards, > > Juliane > > It works for me. You likely have an outdated version of zoo. Make sure you have zoo 1.6-4. Here is the output: > packageDescription("zoo")$Version [1] "1.6-4" > > Lines1 <- "Date Distance [m] + 2006-08-18 22:05:15 1815.798 + 2006-08-18 22:06:35 1815.798 + 2006-08-18 22:08:33 1815.798 + 2006-08-18 22:09:49 1815.798 + 2006-08-18 22:12:50 1815.798 + 2006-08-18 22:16:26 1815.798" > > Lines2 <- "Date Distance [m] + 2006-08-18 09:53:20 0.0 + 2006-08-18 09:59:07 0.0 + 2006-08-18 10:09:20 0.0 + 2006-08-18 10:21:14 0.0 + 2006-08-18 10:34:18 0.0 + 2006-08-18 10:36:44 100.2" > > library(zoo) > library(chron) > > # read in data > > dt <- function(date, time) as.chron(paste(date, time)) > z1 <- read.zoo(textConnection(Lines1), skip = 1, index = list(1, 2), FUN = dt) > z2 <- read.zoo(textConnection(Lines2), skip = 1, index = list(1, 2), FUN = dt) > > # create single zoo object > > z <- na.approx(cbind(z1, z2), na.rm = FALSE) Warning messages: 1: closing unused connection 4 (Lines2) 2: closing unused connection 3 (Lines1) > > # plot -- remove screen=1 if you want separate panels > > plot(z, screen = 1) -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.