[R] POSIX to ts and back to POSIX

About this list Date view Thread view Subject view Author view Attachment view

From: Allen.Joel@epamail.epa.gov
Date: Thu 20 May 2004 - 05:24:38 EST


Message-id: <OFE18C037F.A481D40B-ON85256E99.00687DA9-85256E99.006AA0A3@epamail.epa.gov>


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@epa.gov

______________________________________________
R-help@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


About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Mon 31 May 2004 - 23:05:11 EST