xiao.gang.fan1@libertysurf.fr
2004-Oct-10 17:53 UTC
[Rd] strange behaviour in R 2.0.0 (PR#7275)
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
<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 2Normally 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")
This is the fourth bug report today from Xiao Gang FAN, and we have had no response to replies to the first three. Please do not send bug reports unless you are prepared to take responsibility for them and answer requests for further information. Please read the posting guide and the FAQ and use a meaningful subject line. Now, where is the requested code to reproduce PR#7272? On Sun, 10 Oct 2004 xiao.gang.fan1@libertysurf.fr wrote:> 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 2That code is indeed incorrect, and did fail in 1.9.1: R : Copyright 2004, The R Foundation for Statistical Computing Version 1.9.1 (2004-06-21), ISBN 3-900051-00-3> a = data.frame(x=1:2) > a$y = strptime(c("20010101","20020101"),"%Y%m%d")Error in "$<-.data.frame"(`*tmp*`, "y", value = strptime(c("20010101", : replacement has 9 rows, data has 2 It even failed in 1.8.0. It `worked' in 1.7.0, but did not do what you most likely wanted it to do (see the NEWS for 1.8.0). You cannot sensibly add "POSIXlt" objects to a data frame: you can add "POSIXct" objects. -- Brian D. Ripley, ripley@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595