[R] Unable to create/index a zoo irregular timeseries

jim holtman jholtman at gmail.com
Thu Feb 21 18:10:12 CET 2008


You need to convert to POSIXct since POSIXlt is a vector of size 9.
So do the following:

miedate <- as.POSIXct(strptime(as.character(pressione[,1]),
format="%d-%m-%Y %H:%M:%S"))

There is a newsletter (I forget the issue) that you might want to
refer to on using 'dates'.




On 2/21/08, vittorio <vdemart1 at tin.it> wrote:
> In the text file pressione2008.csv I have the following
>
> "Data","MAX","MIN","Note"
> "07-01-2008 08:00:00", 135, 90, "Eccessi feste, inizio dieta"
> "07-01-2008 18:00:00", 135, 85, ""
> "08-01-2008 08:00:00", 125, 75, ""
>
> which is a collection of blood pressure data at different time of the day.
> I would like to build an its with MIN & MAX blood pressure but being a real
> newbye with zoo I obtain the following
>
> > library(zoo)
> pressione <- data.frame(read.csv("pressione2008.csv"))
>
>  miedate <- strptime(as.character(pressione[,1]), format="%d-%m-%Y %H:%M:%S")
>
> > miedate
> [1] "2008-01-07 08:00:00" "2008-01-07 18:00:00" "2008-01-08 08:00:00"
>
> > str(miedate)
>  POSIXlt[1:9], format: "2008-01-07 08:00:00" "2008-01-07 18:00:00" ...
>
> > ts<- as.zoo(matrix(pressione[,2:3],ncol=2), miedate)
> > ts
> Error in Ops.POSIXt(freq, d) : * not defined for "POSIXt" objects
>
> > ts<- zoo(matrix(pressione[,2:3],ncol=2), miedate)
> Error in order(x, ..., na.last = na.last, decreasing = decreasing) :
>  unimplemented type 'list' in 'orderVector1'
> In addition: Warning message:
> In zoo(matrix(pressione[, 2:3], ncol = 2), miedate) :
>  some methods for "zoo" objects do not work if the index entries
> in 'order.by' are not unique
>
> >
>
> Please help
>
> Ciao
> Vittorio
>
> ______________________________________________
> R-help at 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.
>


-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?



More information about the R-help mailing list