Re: [Rd] strange behaviour in R 2.0.0 (PR#7275)

From: Gabor Grothendieck <ggrothendieck_at_myway.com>
Date: Mon 11 Oct 2004 - 02:15:09 EST

 <xiao.gang.fan1 <at> libertysurf.fr> writes:

>
> Full_Name: Xiao Gang FAN
> Version: R 2.0.0
> OS: Windows
> Submission from: (NULL) (82.226.247.142)
>
> The following codes worked for R 1.9.1
>
> > a = data.frame(x=1:2)
> > a$y = strptime(c("20010101","20020101"),"%Y%m%d")
>
> this no longer works for R 2.0.0:
>
> Error in "$<-.data.frame"(`*tmp*`, "y", value = list(sec = c(0, 0), min = c
(0,
> :
> replacement has 9 rows, data has 2

Normally if one wants to store a POSIXt object in a data frame, one uses POSIXct, not POSIXlt:

a <- data.frame(x = 1:2)
a$y <- as.POSIXct(strptime(c("20010101","20020101"),"%Y%m%d"))

Actually in this instance you are not using times at all so you might be better off using the simpler Date class:

a <- data.frame(x = 1:2)
a$y <- as.Date(c("20010101","20020101"),"%Y%m%d")



R-devel@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Mon Oct 11 02:24:24 2004

This archive was generated by hypermail 2.1.8 : Wed 03 Nov 2004 - 22:45:21 EST