For some reason I thought that I could read some text into dates without a separator? Am I wrong? Examples Works, it appears ccc <- c("2011-04-07", "1989-10-12") x <- strptime(ccc, "%Y-%m-%d") Does not work ddd <- c("20110407", "19891012") y <- strptime(ccc, "%Y%m%d") Does this mean I would have to parse the data in ddd and add separators? Or am I missing some option in the help on strptime? Thanks
On Wed, Mar 23, 2011 at 03:22:52PM -0700, John Kane wrote:> For some reason I thought that I could read some text into dates without a separator? Am I wrong? > > Examples > > Works, it appears > ccc <- c("2011-04-07", "1989-10-12") > x <- strptime(ccc, "%Y-%m-%d") > > Does not work > ddd <- c("20110407", "19891012") > y <- strptime(ccc, "%Y%m%d") > > Does this mean I would have to parse the data in ddd and add separators? > Or am I missing some option in the help on strptime? > ...Did you mean d <- strptime(ddd, "%Y%m%d") up there? ccc is the form that has the hyphens. Using ddd works for me:> format(Sys.time(), "%H:%M:%OS3")[1] "15:31:10.113"> ddd <- c("20110407", "19891012") > strptime(ddd, "%Y%m%d")[1] "2011-04-07" "1989-10-12">and ?strptime clearly shows an example without separators. Peace, david -- David H. Wolfskill r at catwhisker.org Depriving a girl or boy of an opportunity for education is evil. See http://www.catwhisker.org/~david/publickey.gpg for my public key. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 196 bytes Desc: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20110323/c0fe0d87/attachment.bin>
Thanks to David and William. I hate it when a typo is all it is but I am a lousy typist. --- On Wed, 3/23/11, David Wolfskill <r at catwhisker.org> wrote:> From: David Wolfskill <r at catwhisker.org> > Subject: Re: [R] Separators in strptime---needed? > To: "John Kane" <jrkrideau at yahoo.ca> > Cc: "R R-help" <r-help at stat.math.ethz.ch> > Received: Wednesday, March 23, 2011, 6:35 PM > On Wed, Mar 23, 2011 at 03:22:52PM > -0700, John Kane wrote: > > For some reason I? thought that I could read some > text into dates without a separator?? Am I wrong? > > > > Examples > > > > Works,? it appears > > ccc <- c("2011-04-07", "1989-10-12") > > x <- strptime(ccc, "%Y-%m-%d") > > > > Does not work > > ddd <- c("20110407", "19891012") > > y <- strptime(ccc, "%Y%m%d") > > > > Does this mean I would have to parse the data in ddd > and add separators? > > Or am I missing some option in the help on strptime? > > ... > > Did you mean > > d <- strptime(ddd, "%Y%m%d") > > up there?? ccc is the form that has the hyphens. > > Using ddd works for me: > > > format(Sys.time(), "%H:%M:%OS3") > [1] "15:31:10.113" > > ddd <- c("20110407", "19891012") > > strptime(ddd, "%Y%m%d") > [1] "2011-04-07" "1989-10-12" > > > > and ?strptime clearly shows an example without separators. > > Peace, > david > -- > David H. Wolfskill??? ??? > ??? ??? r at catwhisker.org > Depriving a girl or boy of an opportunity for education is > evil. > > See http://www.catwhisker.org/~david/publickey.gpg for my > public key. >