Try this: format(strptime(tst, "%H:%M:%S"), "%M")
On Wed, Oct 15, 2008 at 6:54 PM, Redding, Matthew < [EMAIL PROTECTED]> wrote: > Hi All, > > Is there a means to extract the "10" from "23:10:34" in one pass using > strsplit (or something else)? > tst <- "23:10:34" > > For example my attempt > strsplit(as.character(tst),"^[0-9]*:") > gives > [[1]] > [1] "" "" "34" > > Obviously it is matching the first two instances of [0-9]. Note that > there may be only one digit before the first ":". > > How do I anchor the match to the begginning or better still, just > extract the number I want in one pass? > > I can see that I can add "begin" to the beginning of the string, and > match that and do something similar at the end, getting rid of empty > strings > etc - but I think it would take about 3 passess - and the files are > large. And besides that code would be unlovely. > > Kind regards, > > > Matt Redding > ********************************DISCLAIMER**************...{{dropped:15}} > > ______________________________________________ > R-help@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. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O [[alternative HTML version deleted]]
______________________________________________ R-help@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.