Hi, When I try d <- as.difftime("6-08:18:33",format=%d-%H:%M:%S") I get: Error: unexpected SPECIAL in "as.difftime("6-08:18:33",format=%d-%" Am I correct in thinking that it is not possible to do something like this, because there is no character string for the format which corresponds to "number of days"? I could misuse "%j" for "day of the year as a decimal number", but ultimately the "difftime" object is still a data, rather than a length of time and I should be looking at a package like 'lubridate' instead. Is that the case? Cheers, Loris -- Dr. Loris Bennett (Mr.) ZEDAT, Freie Universit?t Berlin Email loris.bennett at fu-berlin.de
Try d <- as.difftime("6-08:18:33","%d-%H:%M:%S") John Kane Kingston ON Canada> -----Original Message----- > From: loris.bennett at fu-berlin.de > Sent: Mon, 8 Aug 2016 11:37:33 +0200 > To: r-help at stat.math.ethz.ch > Subject: [R] No "number of days" format for 'difftime'? > > Hi, > > When I try > > d <- as.difftime("6-08:18:33",format=%d-%H:%M:%S") > > I get: > > Error: unexpected SPECIAL in "as.difftime("6-08:18:33",format=%d-%" > > Am I correct in thinking that it is not possible to do something like > this, because there is no character string for the format which > corresponds to "number of days"? > > I could misuse "%j" for "day of the year as a decimal number", but > ultimately the "difftime" object is still a data, rather than a length > of time and I should be looking at a package like 'lubridate' instead. > Is that the case? > > Cheers, > > Loris > > -- > Dr. Loris Bennett (Mr.) > ZEDAT, Freie Universit?t Berlin Email loris.bennett at fu-berlin.de > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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.____________________________________________________________ Can't remember your password? Do you need a strong and secure password? Use Password manager! It stores your passwords & protects your account.
ruipbarradas at sapo.pt
2016-Aug-08 09:56 UTC
[R] No "number of days" format for 'difftime'?
Hello, You're missing a double quotes. Right after format Hope this helps, Rui Barradas ? Citando Loris Bennett <loris.bennett at fu-berlin.de>:> Hi, > > When I try > > d <- as.difftime("6-08:18:33",format=%d-%H:%M:%S") > > I get: > > Error: unexpected SPECIAL in "as.difftime("6-08:18:33",format=%d-%" > > Am I correct in thinking that it is not possible to do something like > this, because there is no character string for the format which > corresponds to "number of days"? > > I could misuse "%j" for "day of the year as a decimal number", but > ultimately the "difftime" object is still a data, rather than a length > of time and I should be looking at a package like 'lubridate' instead. > Is that the case? > > Cheers, > > Loris > > -- > Dr. Loris Bennett (Mr.) > ZEDAT, Freie Universit?t Berlin? ? ? ? ?Email loris.bennett at fu-berlin.de > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.htmland provide commented, > minimal, self-contained, reproducible code.? [[alternative HTML version deleted]]
Hi, I was probably misled by the, to my mind, esoteric error message into thinking the error was more subtle. Something like "unmatched quotes" might have helped me recognise that I was just being dopey. Thanks to John and Rui. Loris <ruipbarradas at sapo.pt> writes:> Hello, > > You're missing a double quotes. Right after format> > Hope this helps, > > Rui Barradas > ? > > Citando Loris Bennett <loris.bennett at fu-berlin.de>: > >> Hi, >> >> When I try >> >> d <- as.difftime("6-08:18:33",format=%d-%H:%M:%S") >> >> I get: >> >> Error: unexpected SPECIAL in "as.difftime("6-08:18:33",format=%d-%" >> >> Am I correct in thinking that it is not possible to do something like >> this, because there is no character string for the format which >> corresponds to "number of days"? >> >> I could misuse "%j" for "day of the year as a decimal number", but >> ultimately the "difftime" object is still a data, rather than a length >> of time and I should be looking at a package like 'lubridate' instead. >> Is that the case? >> >> Cheers, >> >> Loris >> >> -- >> Dr. Loris Bennett (Mr.) >> ZEDAT, Freie Universit?t Berlin? ? ? ? ?Email loris.bennett at fu-berlin.de >> >> ______________________________________________ >> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.htmland provide commented, >> minimal, self-contained, reproducible code. > > ? > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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.-- Dr. Loris Bennett (Mr.) ZEDAT, Freie Universit?t Berlin Email loris.bennett at fu-berlin.de