Is your question how to convert a vector v containing seconds since the Epoch to POSIXct? If that's it, then one way is:
now <- Sys.time() Epoch <- now - as.numeric(now) Epoch + v <Allen.Joel <at> epamail.epa.gov> writes: : : I am trying to use POSIX datetime objects rather than chron datetime : objects but am having difficulty with POSIX in a time series. My : question: Once a POSIXct vector is bound to a time series, is there a : function to convert back to POSIXct? The following code demonstrates : what I am trying to do. : : > ts(as.POSIXct(strptime(tmp,"%m/%d/%Y %H:%M:%S")),freq=1440) : Time Series: : Start = c(1, 1) : End = c(1, 10) : Frequency = 1440 : [1] 1074022572 1074022632 1074022693 1074022753 1074022813 1074022874 : 1074022934 1074022994 1074023055 1074023115 : attr(,"tzone") : [1] : > as.POSIXct(ts(as.POSIXct(strptime(tmp,"%m/%d/%Y : %H:%M:%S")),freq=1440)) : Error in as.POSIXct.default(ts(as.POSIXct(strptime(tmp, "%m/%d/%Y : %H:%M:%S")), : : Don't know how to convert `ts(as.POSIXct(strptime(tmp, "%m/%d/%Y : %H:%M:%S")), freq = 1440)' to class "POSIXct" : : this does not work either : : > as.POSIXct(as.numeric(as.POSIXct(strptime(tmp,"%m/%d/%Y %H:%M:%S")))) : Error in as.POSIXct.default(as.numeric(as.POSIXct(strptime(tmp, : "%m/%d/%Y %H:%M:%S")))) : : Don't know how to convert `as.numeric(as.POSIXct(strptime(tmp, : "%m/%d/%Y %H:%M:%S")))' to class "POSIXct" : : Thanks in advance. : : H. Joel Allen, PhD : Environmental Scientist : U.S. EPA : NRMRL, Water Quality Management Branch : 26 W. Martin Luther King Dr : Cincinnati, OH 45268 : : Phone: 513 487-2806 : Fax: 513 569-7052 : Email: allen.joel <at> epa.gov : : ______________________________________________ : R-help <at> stat.math.ethz.ch mailing list : https://www.stat.math.ethz.ch/mailman/listinfo/r-help : PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html : : ______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
