[R] How to create an array/list/vector of POSIXlt objects?

bo bozhou1981 at gmail.com
Sun Feb 17 21:11:55 CET 2008


Hi Guys,

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

I'm hit on problems like this

> 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 a matrix so that it can not be embedded into an
element of the array?

Any suggestions?

Cheers,

Bo



More information about the R-help mailing list