我希望 df3 和 df4 具有相同的输出,但它不是,有什么区别?
tim.seq<-seq(as.POSIXlt("2013-07-01 00:00:00",origin = "1960-01-01",tz="GMT"),
as.POSIXlt("2013-07-16 12:00:00",origin = "1960-01-01",tz="GMT"),by="12 hours")
df<-data.frame(times=factor(tim.seq))
df2<-df
df2[,"times"]<-as.POSIXlt(as.character(df2[,"times"]),origin = "1960-01-01",tz="GMT")
df3<-df
df3$times<-as.POSIXlt(as.character(df3[,"times"]),origin = "1960-01-01",tz="GMT")
for(i in df3$times) print(i)
t<-as.POSIXlt(as.character(df[,"times"],origin = "1960-01-01",tz="GMT"))
df4<-data.frame(times=t)
for(i in df4$times) print(i)