: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
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
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
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
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, ":")
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
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
7 matches
Mail list logo