On Wed, Mar 14, 2012 at 12:43 PM, knavero <knav...@gmail.com> wrote: > attached http://r.789695.n4.nabble.com/file/n4472408/dataout_2471_843.csv > dataout_2471_843.csv >
Here is how the problem can be presented in a self contained, minimal, reproducible fashion (as per last two lines on every message to r-help): library(zoo) Lines <- "Meter ID ,Date / Time ,KW(ch: 1 set:0) MCAS-B-2471 ,2/11/12 12:45 ,0.08 MCAS-B-2471 ,2/11/12 13:00 ,8.92 MCAS-B-2471 ,2/11/12 13:15 ,7.2 " # poster's read.zoo statement except for use of text=Lines rawData <- read.zoo(text = Lines, header = TRUE, FUN = as.chron, format = "%m/%d/%Y %H:%M", index.column = 2, sep = ",", aggregate = function(x) tail(x, 1)) >From this we see that its trying to read character data into a zoo object which is not allowed. We can either do this to remove the offending column (note that having dropped the character column the index column becomes column 1 so we can drop the index= argument): tail1 <- function(x) tail(x, 1) fmt <- "%m/%d/%Y %H:%M" rawData <- read.zoo(text = Lines, FUN = as.chron, format = fmt, header = TRUE, sep = ",", aggregate = tail1, colClasses = c("NULL", NA, NA)) or if we want to split it into columns with one column per Meter ID we could do it like this (which in this case will give the same result as there is only one Meter ID in Lines): rawData <- read.zoo(text = Lines, FUN = as.chron, format = fmt, split = 1, index = 2, header = TRUE, sep = ",", aggregate = tail1) -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com ______________________________________________ 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.