[R] Possible Bug?
Prof Brian Ripley
ripley at stats.ox.ac.uk
Tue Nov 27 10:23:05 CET 2001
The only bug is in your reading of the documentation!
`%H' Hours as decimal number (00-23).
`%I' Hours as decimal number (01-12).
So if you want to use an AM/PM indicator, you need
strptime(x, "%m/%d/%Y %I:%M:%S %p")
[1] "2001-11-20 00:00:00" "2001-11-20 12:00:00"
AM/PM indicators are ignored with %H.
(And in case anyone says that the help page should say so: none of the
underlying OS's man pages I checked does so, so I had to read the code to
find out. You could have done so too.)
On Mon, 26 Nov 2001, Shawn Way wrote:
> I have this problem with the POSIX functions
>
> >version
> _
> platform i386-pc-mingw32
> arch x86
> os Win32
> system x86, Win32
> status
> major 1
> minor 3.1
> year 2001
> month 08
> day 31
> language R
> >
> > dates <- c("11/20/2001","11/20/2001")
> dates <- c("11/20/2001","11/20/2001")
> > times <- c("12:00:00 AM","12:00:00 PM")
> times <- c("12:00:00 AM","12:00:00 PM")
> > x <- paste(dates,times)
> x <- paste(dates,times)
> > z1 <- strptime(x[1], "%m/%d/%Y %H:%M:%S %p")
> z1 <- strptime(x[1], "%m/%d/%Y %H:%M:%S %p")
> > z1
> z1
> [1] "2001-11-20 12:00:00"
> > z2 <- strptime(x[2], "%m/%d/%Y %H:%M:%S %p")
> z2 <- strptime(x[2], "%m/%d/%Y %H:%M:%S %p")
> > z1 == z2
> z1 == z2
> [1] TRUE
> >
>
> As you can see, this is a problem, I believe...
>
>
>
> "Don't rush me, you rush a miracle, you get a rotten miracle."
> -Miracle Max, The Princess Bride
>
>
> Shawn Way
>
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list