Re: [R] strptime format = "%H:%M:%OS6"

From: David Winsemius <dwinsemius_at_comcast.net>
Date: Tue, 15 Feb 2011 14:09:58 -0500

On Feb 15, 2011, at 11:39 AM, Sam Steingold wrote:

> I read a dataset with times in them, e.g., "09:31:29.18761".
> I then parse them:

>> all$X.Time <- strptime(all$X.Time, format = "%H:%M:%OS6");

> and get a vector of NAs (how do I check that except for a visual
> inspection?)
> then I do
>> options("digits.secs"=6);
>> all$X.Time <- strptime(all$X.Time, format = "%H:%M:%OS");

> and it, apparently, works:
>> all$X.Time[2]-all$X.Time[1]

> Time difference of 5.12188 secs
> so, why doesn't format = "%H:%M:%OS6" work as documented?

I don't know. I get similar results on a Mac (not the most recent version of R obviously). I interpreted the section to mean that the format string was just "%OS<n>" but tried it both ways with identical non-results.

 > x <- "09:31:29.18761"
 >
 > y <- strptime(x, format = "%OS");
 > y

[1] "2011-02-15 00:00:09"
 > x <- "09:31:29.18761"
 >
 > y <- strptime(x, format = "%OS6");
 > y

[1] NA
 > y <- strptime(x, format = "%H:%M:%OS3");  > y
[1] NA

Also got NAs with %OS1 through %OS5

 > sessionInfo()
R version 2.12.1 (2010-12-16)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)

locale:
[1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats graphics grDevices utils datasets methods [7] base

other attached packages:
[1] sos_1.3-0 brew_1.0-4 lattice_0.19-13

loaded via a namespace (and not attached): [1] grid_2.12.1 tools_2.12.1

> --
> Sam Steingold (http://sds.podval.org/) on CentOS release 5.3 (Final)

David Winsemius, MD
West Hartford, CT



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. Received on Tue 15 Feb 2011 - 22:36:13 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 16 Feb 2011 - 01:10:14 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive