Re: [R] POSIXct coerced into numeric when filling a data frame

2012-09-24 Thread arun
Hi, You can also try this:  x1<-list(a=data.frame(x[["a"]]),b=data.frame(x[["b"]])) library(plyr) x2<-do.call(rbind.fill,x1) colnames(x2)<-c("a","b") x2first<-subset(x2,format(a,"%Y-%m-%d")=="2011-10-30" )  x2second<-subset(x2,format(b,"%Y-%m-%d")=="2011-10-30" ) y<-data.frame(t(data.frame(a=x2fir

Re: [R] POSIXct coerced into numeric when filling a data frame

2012-09-24 Thread arun
Hi, Upon running your code, the "y" I am getting is: y #  ID  first second #1  a 1320003900 1320004800 #2  b 1320003000 1320003900 This you can convert back by: within(y,{first<-as.POSIXct(first,origin="1970-01-01");second<-as.POSIXct(second,origin="1970-01-01")}) #  ID   first

Re: [R] POSIXct coerced into numeric when filling a data frame

2012-09-24 Thread jim holtman
Try this; does away with the 'for', but have to convert back to POSIXct since sapply strips off the class: > x<-list() > x[["a"]]<-as.POSIXct(c("2011-08-27 10:45:00 GMT", "2011-10-30 15:45:00 GMT", > "2011-10-30 16:00:00 GMT", "2012-06-22 09:30:00 GMT", "2012-06-22 10:00:00 > GMT")) > x[["b"]]<

Re: [R] POSIXct coerced into numeric when filling a data frame

2012-09-24 Thread arun
HI, Try this: dat1<-do.call(data.frame,x) dat1<-data.frame(ID=letters[1:4],dat1) dat1 #  ID   first  second #1  a 2011-08-27 10:45:00 2011-08-27 11:00:00 #2  b 2011-10-30 15:45:00 2011-10-30 15:30:00 #3  c 2011-10-30 16:00:00 2011-10-30 15:45:00 #4  d 2012-06-22 09:30:00 201