%OS on output

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

%OS on output

R devel mailing list
R help on 'strptime' has the following in "Details" section.
Specific to R is ‘%OSn’, which for output gives the seconds truncated to ‘0 <= n <= 6’ decimal places (and if ‘%OS’ is not followed by a digit, it uses the setting of ‘getOption("digits.secs")’, or if that is unset, ‘n = 3’).

In reality, for output, if '%OS' is not followed by a digit and getOption("digits.secs") is unset, the output has no fractional part, as if n = 0 is used.

> getOption("digits.secs")
NULL
> z <- strptime("20/2/06 11:16:16.683", "%d/%m/%y %H:%M:%OS")
> format(z, "%OS")
[1] "16"

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: %OS on output

Joshua Ulrich
On Wed, Feb 24, 2016 at 10:40 AM, Suharto Anggono Suharto Anggono via
R-devel <[hidden email]> wrote:
> R help on 'strptime' has the following in "Details" section.
> Specific to R is ‘%OSn’, which for output gives the seconds truncated to ‘0 <= n <= 6’ decimal places (and if ‘%OS’ is not followed by a digit, it uses the setting of ‘getOption("digits.secs")’, or if that is unset, ‘n = 3’).
>
> In reality, for output, if '%OS' is not followed by a digit and getOption("digits.secs") is unset, the output has no fractional part, as if n = 0 is used.
>
That's because n = 0 _is_ used, and appears to have always been the
default (since the logic was added in r37395).  So this appears to be
a typo in the documentation (the comment about "n=3" when digits.secs
is unset was added in r37439).

>> getOption("digits.secs")
> NULL
>> z <- strptime("20/2/06 11:16:16.683", "%d/%m/%y %H:%M:%OS")
>> format(z, "%OS")
> [1] "16"
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



--
Joshua Ulrich  |  about.me/joshuaulrich
FOSS Trading  |  www.fosstrading.com
R/Finance 2016 | www.rinfinance.com

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel