[R] Help on zoo and datetime series

Achim Zeileis Achim.Zeileis at wu-wien.ac.at
Mon May 8 22:27:13 CEST 2006


On Mon, 8 May 2006 22:09:45 +0200 domenico.mozzanica at alice.it wrote:

> 
> Hello,
> i would like to import this txt file:
> 
> Giorno;PM10
> 2006-01-01 10:10;10.3
> 2006-02-02 20:22;50.3
> 2006-03-03 23:33;20.1
> .........
> 
> 
> As it's an irregular time series i use zoo as follow:
> 
> require(zoo)
> z <- read.table("c:\\1.csv", sep=";", na.strings="-999", header=TRUE)
> q <- zoo(z$PM10, strptime(as.character(z$Giorno),"%Y-%m-%d %H:%M"))
> 
> At this point this error message appears:
> 
> Errore in order(x, ..., na.last = na.last, decreasing = decreasing) : 
>         tipo 'list' non implementato in 'orderVector1'

Your datetime vector is of class POSIXlt which is essentially a list.
Better use POSIXct:

q <- zoo(z$PM10,
  as.POSIXct(strptime(as.character(z$Giorno),"%Y-%m-%d %H:%M")))

However, it becomes even simpler via read.zoo():

z <- read.zoo("c:\\1.csv", sep = ";", header = TRUE,
  na.strings = "-999", tz = "CET")

hth,
Z

> 
> I can't understand how can I import such a file. Is there anybody who
> can help me?
> 
> Thanks
> 
> Domenico
> 
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>




More information about the R-help mailing list