Dear List,
I am having a problem with dates and I would like to understand what is going
on. Below is an example. I can produce a date/time using as.POSIXct, but I am
trying to combine two as.POSIXct objects and keep getting strange results. I
thought I was using the wrong origin, but according to
structure(0,class="Date") I am not (see below). In my example a is a simple
date/time object, b combines it using rbind(), c converts b to a date/time
object again using as.POSIXct and gives the incorrect time, and d combines a
using c() and gives the correct time. Why doesn't c give me the correct answer?
Thanks,
Tim
> a<-as.POSIXct("2000-01-01 12:00:00")
> a
[1] "2000-01-01 12:00:00 HST"
> b<-rbind(a,a)
> b
[,1]
a 946764000
a 946764000
> c<-as.POSIXct(b,origin="1970-01-01")
> c
[1] "2000-01-01 22:00:00 HST"
[2] "2000-01-01 22:00:00 HST"
> d<-c(a,a)
> d
[1] "2000-01-01 12:00:00 HST"
[2] "2000-01-01 12:00:00 HST"
> structure(0,class="Date")
[1] "1970-01-01"
Tim Clark
Department of Zoology
University of Hawaii
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.