Re: [R] strsplit and regex

2008-10-15 Thread Redding, Matthew
:38 AM >To: Redding, Matthew >Cc: r-help@r-project.org >Subject: Re: [R] strsplit and regex > >Here are several solutions: > >#1 ># replace first three and last 3 characters with nothing x <- >c("23:10:34", "01:02:03") gsub("^...|...$", &q

Re: [R] strsplit and regex

2008-10-15 Thread Gabor Grothendieck
Here are several solutions: #1 # replace first three and last 3 characters with nothing x <- c("23:10:34", "01:02:03") gsub("^...|...$", "", x) #2 # backref = -1 says extract the portion in parens # it would have returned a list so we use simplify = c library(gsubfn) strapply(x, ":(..):", backref

Re: [R] strsplit and regex

2008-10-15 Thread Henrique Dallazuanna
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 > s

Re: [R] strsplit and regex

2008-10-15 Thread Prof Brian Ripley
dding -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Redding, Matthew Sent: Thursday, 16 October 2008 7:54 AM To: r-help@r-project.org Subject: [R] strsplit and regex Hi All, Is there a means to extract the "10" from "23:10:34" in on

Re: [R] strsplit and regex

2008-10-15 Thread Erik Iverson
Matthew - Redding, Matthew 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" Why not simply, strsplit(tst, ":")

Re: [R] strsplit and regex

2008-10-15 Thread Redding, Matthew
er 2008 7:54 AM >To: r-help@r-project.org >Subject: [R] strsplit and regex > >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 attem

[R] strsplit and regex

2008-10-15 Thread Redding, Matthew
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