Dear List,
I am having problems converting a file with fractional seconds to class POSIXct. I have set my options to include digits.secs and my format to just time, but my output is the current date with my time lacking the fractions of a second. For example:
options(digits.secs=3)
t<-c("06:00:00.100","06:00:01.231")
myt<-as.POSIXct(t,format="%H:%M:%S")
myt
[1] "2009-05-26 06:00:00 HST" "2009-05-26 06:00:01 HST"
I would like the output to be just time with fractional seconds. I.e.
06:00:00.100,06:00:01.231
I have also tried Chron times() which did not work either. Interestingly, Sys.time() does produce fractional seconds, so I know the options are working.
I would appreciate your help and suggestions.
Aloha,
Tim
Tim Clark
Department of Zoology
University of Hawaii
Problem with fractional seconds
4 messages · Tim Clark, Gabor Grothendieck, Seeliger.Curt at epamail.epa.gov
Try this:
as.POSIXct(c("06:00:00.100","06:00:01.231"), format = "%H:%M:%S%OS")
[1] "2009-05-26 06:00:00.100 EDT" "2009-05-26 06:00:00.231 EDT"
On Tue, May 26, 2009 at 5:52 PM, Tim Clark <mudiver1200 at yahoo.com> wrote:
Dear List,
I am having problems converting a file with fractional seconds to class POSIXct. ?I have set my options to include digits.secs and my format to just time, but my output is the current date with my time lacking the fractions of a second. ?For example:
options(digits.secs=3)
t<-c("06:00:00.100","06:00:01.231")
myt<-as.POSIXct(t,format="%H:%M:%S")
myt
[1] "2009-05-26 06:00:00 HST" "2009-05-26 06:00:01 HST"
I would like the output to be just time with fractional seconds. I.e.
06:00:00.100,06:00:01.231
I have also tried Chron times() which did not work either. ?Interestingly, Sys.time() does produce fractional seconds, so I know the options are working.
I would appreciate your help and suggestions.
Aloha,
Tim
Tim Clark
Department of Zoology
University of Hawaii
______________________________________________ R-help at r-project.org 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.
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20090526/f47654ce/attachment-0001.pl>
Its in the second paragraph after the list of % codes.
On Tue, May 26, 2009 at 6:11 PM, <Seeliger.Curt at epamail.epa.gov> wrote:
Thanks for beating me to that, Gabor. ?The %OS format spec isn't in the strptime() docs. ?How else might we have found this for ourselves? cur r-help-bounces at r-project.org wrote on 05/26/2009 02:59:20 PM:
as.POSIXct(c("06:00:00.100","06:00:01.231"), format = "%H:%M:%S%OS")
[1] "2009-05-26 06:00:00.100 EDT" "2009-05-26 06:00:00.231 EDT" On Tue, May 26, 2009 at 5:52 PM, Tim Clark <mudiver1200 at yahoo.com> wrote:
...
options(digits.secs=3)
t<-c("06:00:00.100","06:00:01.231")
myt<-as.POSIXct(t,format="%H:%M:%S")
myt
[1] "2009-05-26 06:00:00 HST" "2009-05-26 06:00:01 HST"
I would like the output to be just time with fractional seconds. I.e.
06:00:00.100,06:00:01.231
-- Curt Seeliger, Data Ranger Raytheon Information Services - Contractor to ORD seeliger.curt at epa.gov 541/754-4638