arun
2014-Feb-07 21:50 UTC
[R] Why does a date frame returning date with a time zone sometimes?
I may have misunderstood your question.? vec1 <- seq(as.POSIXct("2009-01-01 00:00:00",format="%Y-%m-%d %H:%M:%S"),by= '12 hour', length=12) vec1[1:3] #returns with time zone #[1] "2009-01-01 00:00:00 EST" "2009-01-01 12:00:00 EST" #[3] "2009-01-02 00:00:00 EST" If you don't want the time zone info:, strftime(vec1,usetz=FALSE)[1:2] #[1] "2009-01-01 00:00:00" "2009-01-01 12:00:00" Also, you can change the time zone, Sys.setenv(TZ="GMT") ?vec1[1:2] #[1] "2009-01-01 05:00:00 GMT" "2009-01-01 17:00:00 GMT" It is not clear what you want. A.K. I have a date from which returns head(mt, 3) ? ? ? ? ? ? ? ? DateW ? ? ? ? ? ? | ? ? ? ? Date ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? |tempDeg 2 2009-01-01 01:00:00 ? ? ? | ? ? ? ? 2009-01-01 01:00:00 ? ? ? ?| ? ? ? ? ?-23.6 3 2009-01-01 02:00:00 ? ? ? | ? ? ? ? 2009-01-01 02:00:00 ? ? ? ?| ? ? ? ? ?-25.7 4 2009-01-01 03:00:00 ? ? ? | ? ? ? ? 2009-01-01 03:00:00 ? ? ? ?| ? ? ? ? ?-26.5 Why does this return ?a time with MST? mt[1,2] [1] "2009-01-01 01:00:00 MST"