Re: [R] regexpr

2007-07-03 Thread runner
using lapply is so great. That help me a lot. thanks. Stephen Tucker wrote: > > I think you are looking for paste(). > > And you can replace your for loop with lapply(), which will apply regexpr > to > every element of 'mylist' (as the first argument, which is 'pattern'). > 'text' > can be a v

Re: [R] regexpr

2007-06-29 Thread Stephen Tucker
I think you are looking for paste(). And you can replace your for loop with lapply(), which will apply regexpr to every element of 'mylist' (as the first argument, which is 'pattern'). 'text' can be a vector also: mylist <- c("MN","NY","FL") lapply(paste(mylist,"$",sep=""),regexpr,text="Those fro

Re: [R] regexpr

2007-06-29 Thread jim holtman
mylist=c("MN","NY","FL") g=regexpr(paste(mylist[1], "$", sep=""), "Those from MN:") if (g>0) { "On list" } or in a loop for (i in mylist){ if (regexpr(paste(mylist[i], "$", sep="")) > 0){ .code for those from } } On 6/29/07, runner <[EMAIL PROTECTED]> wrote: > > > Hi, >

[R] regexpr

2007-06-29 Thread runner
Hi, I 'd like to match each member of a list to a target string, e.g. -- mylist=c("MN","NY","FL") g=regexpr(mylist[1], "Those from MN:") if (g>0) { "On list" } -- My question is: How to add an end-of-string symbol '$' to the to-match strin

Re: [R] regexpr and parsing question

2007-01-30 Thread Gabor Grothendieck
And here is an alternative to the regular expressions (although again I don't think you really need any of this): > capture.output(dput(strsplit("col1 col2 col3", " ")[[1]])) [1] "c(\"col1\", \"col2\", \"col3\")" On 1/30/07, Gabor Grothendieck <[EMAIL PROTECTED]> wrote: > Both spaces and tabs are

Re: [R] regexpr and parsing question

2007-01-30 Thread Marc Schwartz
On Tue, 2007-01-30 at 17:23 -0500, Kimpel, Mark William wrote: > The main problem I am trying to solve it this: > > I am importing a tab delimited file whose first line contains only one > column, which is a descriptor of the form "col_1 col_2 col_3", i.e. the > colnames are not tab delineated but

Re: [R] regexpr and parsing question

2007-01-30 Thread Gabor Grothendieck
Both spaces and tabs are whitespace so this should be good enough (unless you can have empty fields): read.table("myfile.dat", header = TRUE) See the sep= argument in ?read.table . Although I don't think you really need this, here are some regular expressions for processing a header into the for

[R] regexpr and parsing question

2007-01-30 Thread Kimpel, Mark William
The main problem I am trying to solve it this: I am importing a tab delimited file whose first line contains only one column, which is a descriptor of the form "col_1 col_2 col_3", i.e. the colnames are not tab delineated but are separated by whitespace. I would like to parse this first line and m

Re: [R] regexpr and portability issue

2005-08-03 Thread Prof Brian Ripley
On Tue, 2 Aug 2005, Marco Blanchette wrote: > I am still forging my first arms with R and I am fighting with regexpr() as > well as portability between unix and windoz. I need to extract barcodes from > filenames (which are located between a double and single underscore) as well > as the directory

Re: [R] regexpr and portability issue

2005-08-02 Thread Gabor Grothendieck
Try this. The regular expression says to match - anything - followed by a double underscore - followed by one or more digits - followed by an underscore - followed by anything. The digits have been parenthesized so that they can be referred to in the backreference "\\1".Also use the R fu

[R] regexpr and portability issue

2005-08-02 Thread Marco Blanchette
Dear all-- I am still forging my first arms with R and I am fighting with regexpr() as well as portability between unix and windoz. I need to extract barcodes from filenames (which are located between a double and single underscore) as well as the directory where the filename is residing. Here is

Re: [R] Regexpr with "."

2003-08-14 Thread John Zhang
n 2.54 (1.174.2.17-2003-05-11-exp) >Content-Disposition: inline >Content-Transfer-Encoding: 7bit >Subject: [R] Regexpr with "." >X-BeenThere: [EMAIL PROTECTED] >X-Mailman-Version: 2.1.2 >List-Id: Main R Mailing List: Primary help >List-Help: <mailto:[EMAIL PROTECTED]

Re: [R] Regexpr with "."

2003-08-14 Thread Barry Rowlingson
Thompson, Trevor wrote: It looks like R is treating every character in the string as if it were decimal. I didn't see anything in the help file about "." being some kind of special character. Any idea why R is treating a decimal this way in these functions? Any suggestions how to get around th

Re: [R] Regexpr with "."

2003-08-14 Thread Uwe Ligges
Thompson, Trevor wrote: I'm trying to use the regexpr function to locate the decimal in a character string. Regardless of the position of the decimal, the function returns 1. For example, regexpr(".", "Female.Alabama") [1] 1 attr(,"match.length") [1] 1 In trying to figure out what was going on h

RE: [R] Regexpr with "."

2003-08-14 Thread David Khabie-Zeitoune
Try regexpr("\\.", "Female.Alabama") -Original Message- From: Thompson, Trevor [mailto:[EMAIL PROTECTED] Sent: 13 August 2003 15:47 To: [EMAIL PROTECTED] Subject: [R] Regexpr with "." I'm trying to use the regexpr function to locate the decimal in a c

[R] Regexpr with "."

2003-08-14 Thread Thompson, Trevor
I'm trying to use the regexpr function to locate the decimal in a character string. Regardless of the position of the decimal, the function returns 1. For example, > regexpr(".", "Female.Alabama") [1] 1 attr(,"match.length") [1] 1 In trying to figure out what was going on here, I tried the below

Re: [R] Regexpr with "."

2003-08-14 Thread Ted Harding
On 13-Aug-03 Barry Rowlingson wrote: > Thompson, Trevor wrote: >> I didn't see anything in the help file about "." being some kind >> of special character. Any idea why R is treating a decimal this >> way in these functions? Any suggestions how to get around this? > > '.' is the regexpr charact

Re: [R] Regexpr with "."

2003-08-14 Thread Chuck Cleland
Thompson, Trevor wrote: I'm trying to use the regexpr function to locate the decimal in a character string. Regardless of the position of the decimal, the function returns 1. For example, regexpr(".", "Female.Alabama") You probably want backslashes to indicate that "." should not be treated as

Re: [R] Regexpr with "."

2003-08-14 Thread Jeff Gentry
> I'm trying to use the regexpr function to locate the decimal in a character > string. Regardless of the position of the decimal, the function returns 1. You need to escape it. > gsub("\\.",",","Female.Alabama") [1] "Female,Alabama" __ [EMAIL PROTECT

Re: [R] Regexpr with "."

2003-08-14 Thread Stephen C. Upton
Trevor, The "." is a regex meta-character that matches any character. In order to look specifically for a ".", the you must escape it with a "\", and that "\" must also be escaped, thus, > regexpr("\\.", "Female.Alabama") [1] 7 attr(,"match.length") [1] 1 > HTH steve "Thompson, Trevor" wrote:

[R] Regexpr capturing in R?

2002-12-21 Thread Fredrik Karlsson
msg.pgp Description: PGP message