Dear all, I have a series of time variables such as: 04MAY2011:08:19:00 01JUN2011:09:44:00 28JUN2011:08:08:00 25JUL2011:07:44:00 How could I extract the time as a number, so that I can normalize the times by the first time variable? Thanks, -- View this message in context: http://r.789695.n4.nabble.com/time-extraction-and-normalization-tp4646275.html Sent from the R help mailing list archive at Nabble.com.
Use something like format(as.POSIXct(xxx, format = "STRING"), format = "STRING2") where the appropriate formatting codes can be worked out using the info in ?strptime Cheers, Michael On Mon, Oct 15, 2012 at 9:32 PM, york8866 <yu_york at hotmail.com> wrote:> Dear all, > > I have a series of time variables such as: > > 04MAY2011:08:19:00 > 01JUN2011:09:44:00 > 28JUN2011:08:08:00 > 25JUL2011:07:44:00 > > > How could I extract the time as a number, so that I can normalize the times > by the first time variable? > > Thanks, > > > > > > -- > View this message in context: http://r.789695.n4.nabble.com/time-extraction-and-normalization-tp4646275.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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.
Thanks, The code gives the numbers in "days", how can I adjust the code to directly get the numbers in "hours"? I tried units but it did not work. Thanks1 -- View this message in context: http://r.789695.n4.nabble.com/time-extraction-and-normalization-tp4646275p4646298.html Sent from the R help mailing list archive at Nabble.com.
There are multiple ways. For lack of your example, I would suggest multiplying by 24. Please post the previous context of the thread if you must post from Nabble. --------------------------------------------------------------------------- Jeff Newmiller The ..... ..... Go Live... DCN:<jdnewmil at dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/Batteries O.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --------------------------------------------------------------------------- Sent from my phone. Please excuse my brevity. york8866 <yu_york at hotmail.com> wrote:>Thanks, > >The code gives the numbers in "days", how can I adjust the code to >directly >get the numbers in "hours"? > >I tried units but it did not work. > >Thanks1 > > > >-- >View this message in context: >http://r.789695.n4.nabble.com/time-extraction-and-normalization-tp4646275p4646298.html >Sent from the R help mailing list archive at Nabble.com. > >______________________________________________ >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.