[R] epoch time conversion in R

Jerome Asselin jerome at hivnet.ubc.ca
Thu Feb 27 08:14:07 CET 2003


Install the "chron" package. Then convert the seconds into days...
Also have a look at the help file for chron().

Below is an example.

Cheers,
Jerome

library(chron)
epoch <- c(month=3,day=23,year=1935)
data.seconds <- 1046315697+(0:10)*60*60*24
data.days <- data.seconds/(60*60*24)
fulldate <- chron(data.days,origin.=epoch)
date.only <- chron(floor(data.days),out.format="mon-day-year",origin.=epoch)
plot(date.only,xlab="Date")


On Wednesday 26 February 2003 19:17, Sharad Agarwal wrote:
> Content-Length: 493
> Status: R
> X-Status: N
>
> I have a data file where each entry is indexed by the time in seconds since
> epoch (e.g. 1046315697). Is there an easy way to convert this time value
> into a more friendly time (such as Month-Year) when plotting it?
>
> I searched through the manual, mailing lists, and functions like as.POSIXct
> and strptime, but didn't find what I need.
>
> Thanks,
> Sharad.
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> http://www.stat.math.ethz.ch/mailman/listinfo/r-help

-- 

Jerome Asselin (Jérôme)
Statistical Analyst
British Columbia Centre for Excellence in HIV/AIDS
St. Paul's Hospital
608 - 1081 Burrard Street
Vancouver, British Columbia
CANADA V6Z 1Y6

Email: jerome at hivnet.ubc.ca
Phone: 604 806-9112   Fax: 604 806-9044




More information about the R-help mailing list