The example from the help page for strptime has the following oddity:> dates <- c("02/27/92", "02/27/92", "01/14/92",+ "02/28/92", "02/01/92")> times <- c("23:03:20", "22:29:56", "01:03:30",+ "18:21:03", "16:56:26")> x <- paste(dates, times) > z <- strptime(x, "%m/%d/%y %H:%M:%S") > z[1] "1992-02-27 23:03:20" "1992-02-27 22:29:56" "1992-01-14 01:03:30" "1992-02-28 18:21:03" "1992-02-01 16:56:26"> > length(z)[1] 9>The length is always denoted as 9. Of course this implies that any replacement I want to do with dates etc. always fails with the error: Error in "[[<-.data.frame"(*tmp*, D[I], value = strptime(as.character(x[[D[I]]]), : replacement has 9 rows, data has 5970> > version_ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 1 minor 7.0 year 2003 month 04 day 16 language R>(platform Win2000 professional) Has anyone else encountered this? Thanks, Partha. [[alternate HTML version deleted]]
The strptime object is a structured list object with 9 components. (Type "names(z)" to see the names of the individual components). You may want to convert the strptime object to a POSIXct object using Z = as.POSIXct(z) This is just a vector (of the expected length). Cheers, Dave -----Original Message----- From: r-help-bounces at stat.math.ethz.ch [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of partha_bagchi at hgsi.com Sent: 29 May 2003 16:05 To: r-help at stat.math.ethz.ch Subject: [R] Odd behavior of strptime The example from the help page for strptime has the following oddity:> dates <- c("02/27/92", "02/27/92", "01/14/92",+ "02/28/92", "02/01/92")> times <- c("23:03:20", "22:29:56", "01:03:30",+ "18:21:03", "16:56:26")> x <- paste(dates, times) > z <- strptime(x, "%m/%d/%y %H:%M:%S") > z[1] "1992-02-27 23:03:20" "1992-02-27 22:29:56" "1992-01-14 01:03:30" "1992-02-28 18:21:03" "1992-02-01 16:56:26"> > length(z)[1] 9>The length is always denoted as 9. Of course this implies that any replacement I want to do with dates etc. always fails with the error: Error in "[[<-.data.frame"(*tmp*, D[I], value = strptime(as.character(x[[D[I]]]), : replacement has 9 rows, data has 5970> > version_ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 1 minor 7.0 year 2003 month 04 day 16 language R>(platform Win2000 professional) Has anyone else encountered this? Thanks, Partha. [[alternate HTML version deleted]] ______________________________________________ R-help at stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
partha_bagchi at hgsi.com wrote:> The example from the help page for strptime has the following oddity: > > >> dates <- c("02/27/92", "02/27/92", "01/14/92", > > + "02/28/92", "02/01/92") > >> times <- c("23:03:20", "22:29:56", "01:03:30", > > + "18:21:03", "16:56:26") > >> x <- paste(dates, times) >> z <- strptime(x, "%m/%d/%y %H:%M:%S") >> z > > [1] "1992-02-27 23:03:20" "1992-02-27 22:29:56" "1992-01-14 01:03:30" > "1992-02-28 18:21:03" "1992-02-01 16:56:26" > >>length(z) > > [1] 9 > > The length is always denoted as 9. > Of course this implies that any replacement I want to do with dates etc. > always fails with the error: > > Error in "[[<-.data.frame"(*tmp*, D[I], value = > strptime(as.character(x[[D[I]]]), : > replacement has 9 rows, data has 5970 > >>version > > _ > platform i386-pc-mingw32 > arch i386 > os mingw32 > system i386, mingw32 > status > major 1 > minor 7.0 > year 2003 > month 04 > day 16 > language R > > (platform Win2000 professional) > > Has anyone else encountered this? > > Thanks, > Partha.Hint, from ?POSIXlt: "Class "POSIXlt" is a named list of [9] vectors representing ..." Uwe Ligges
I guess I got confused by the fact that I didn't have to convert to POSIXct in 1.5.1 where I had tested the code I was using. Retesting in 1.7.0 resulted in the error. Thanks, Partha. "David Khabie-Zeitoune" <dave at evocapital.com> Sent by: r-help-bounces at stat.math.ethz.ch 05/29/2003 11:26 AM Please respond to dave To: <partha_bagchi at hgsi.com>, <r-help at stat.math.ethz.ch> cc: Subject: RE: [R] Odd behavior of strptime The strptime object is a structured list object with 9 components. (Type "names(z)" to see the names of the individual components). You may want to convert the strptime object to a POSIXct object using Z = as.POSIXct(z) This is just a vector (of the expected length). Cheers, Dave -----Original Message----- From: r-help-bounces at stat.math.ethz.ch [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of partha_bagchi at hgsi.com Sent: 29 May 2003 16:05 To: r-help at stat.math.ethz.ch Subject: [R] Odd behavior of strptime The example from the help page for strptime has the following oddity:> dates <- c("02/27/92", "02/27/92", "01/14/92",+ "02/28/92", "02/01/92")> times <- c("23:03:20", "22:29:56", "01:03:30",+ "18:21:03", "16:56:26")> x <- paste(dates, times) > z <- strptime(x, "%m/%d/%y %H:%M:%S") > z[1] "1992-02-27 23:03:20" "1992-02-27 22:29:56" "1992-01-14 01:03:30" "1992-02-28 18:21:03" "1992-02-01 16:56:26"> > length(z)[1] 9>The length is always denoted as 9. Of course this implies that any replacement I want to do with dates etc. always fails with the error: Error in "[[<-.data.frame"(*tmp*, D[I], value strptime(as.character(x[[D[I]]]), : replacement has 9 rows, data has 5970> > version_ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 1 minor 7.0 year 2003 month 04 day 16 language R>(platform Win2000 professional) Has anyone else encountered this? Thanks, Partha. [[alternate HTML version deleted]] ______________________________________________ R-help at stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help ______________________________________________ R-help at stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.