[R] How to make a vector/list/array of POSIXlt object?

From: Bo Zhou <bozhou1981_at_hotmail.com>
Date: Sun, 17 Feb 2008 20:45:31 +0000

Hi Guys,

I'm cooking up my time series code. I want a data frame with first column as timestamp in POSIXlt format.

I hit on this the problem of how to create an array/list/vector of POSIXlt objects. Code is as follows

> dtt=array(dim = 2)
> t=as.POSIXlt( strptime("07/12/07 13:20:01", "%m/%d/%Y %H:%M:%S",tz="GMT"))
> dtt

[1] NA NA

> t
[1] "0007-07-12 13:20:01 GMT"
> dtt[1]=t
Warning message:
In dtt[1] = t :
  number of items to replace is not a multiple of replacement length > class(dtt)
[1] "list"

> class(t)
[1] "POSIXt" "POSIXlt"
> unclass(t)
$sec
[1] 1

$min
[1] 20

$hour
[1] 13

$mday
[1] 12

$mon
[1] 6

$year
[1] -1893

$wday
[1] 4

$yday
[1] 192

$isdst
[1] 0

attr(,"tzone")
[1] "GMT"
Seems like POSIXlt is matrix in this case.

Any suggestions?

Cheers,

B



[[elided Hotmail spam]]

        [[alternative HTML version deleted]]



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. Received on Sun 17 Feb 2008 - 20:50:21 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 17 Feb 2008 - 21:30:14 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive