Re: [R] GREP - Choosing values between two borders

2007-04-18 Thread jim holtman
Another way you can do it, if the data has the pattern shown in your sample, it to select all the lines that start with a numeric: input - FILE-CONTENT ## + EXAM NUM:2 + - + EXAM #1 + ASTIG:-2.4D + AXIS:4.8 + START OF HEIGHT DATA + 0 0.0 0. + 0 0.1

[R] GREP - Choosing values between two borders

2007-04-17 Thread Felix Wave
Hello, I import datas from an file with: readLines But I need only a part of all measurments of this file. These are between two borders START and END. Can you tell me the syntax of grep(), to choose values between two borders? My R Code was not succesful, and I can't finde anything in the help.

Re: [R] GREP - Choosing values between two borders

2007-04-17 Thread Gabor Grothendieck
You can adapt this to your situation: http://finzi.psych.upenn.edu/R/Rhelp02a/archive/22195.html On 4/17/07, Felix Wave [EMAIL PROTECTED] wrote: Hello, I import datas from an file with: readLines But I need only a part of all measurments of this file. These are between two borders START and

[R] grep searching for sequence of 3 consecutive upper case letters

2006-11-06 Thread Lapointe, Pierre
Hello, I need to identify all elements which have a sequence of 3 consecutive upper case letters, anywhere in the string. I tested my grep expression on this site: http://regexlib.com/RETester.aspx But when I try it in R, it does not filter anything. str -c(AGH, this WOUld be good, Not Good at

Re: [R] grep searching for sequence of 3 consecutive upper case letters

2006-11-06 Thread David Barron
Try str[grep('[[:upper:]]{3}',str)] On 06/11/06, Lapointe, Pierre [EMAIL PROTECTED] wrote: Hello, I need to identify all elements which have a sequence of 3 consecutive upper case letters, anywhere in the string. I tested my grep expression on this site: http://regexlib.com/RETester.aspx

Re: [R] grep searching for sequence of 3 consecutive upper case letters

2006-11-06 Thread rfrancois
Quoting David Barron [EMAIL PROTECTED]: Try str[grep('[[:upper:]]{3}',str)] or more efficiently : grep('[[:upper:]]{3}', str, value = TRUE) On 06/11/06, Lapointe, Pierre [EMAIL PROTECTED] wrote: Hello, I need to identify all elements which have a sequence of 3 consecutive upper case

Re: [R] grep searching for sequence of 3 consecutive upper case letters

2006-11-06 Thread Peter Dalgaard
ways. Don't expect the RETester to hold the Final Truth; it seems to relate to a particular programming environment, which is not R. grep('[A-Z]{3}', str, perl=TRUE) [1] 1 2 Not only that, but grep('[ABCDEFGHIJKLMNOPQRSTUVWXYZ]{3}', str) [1] 1 2 Hint: What is your collating sequence

Re: [R] grep function with patterns list...

2006-10-17 Thread Martin Maechler
Anupam == Anupam Tyagi [EMAIL PROTECTED] on Mon, 16 Oct 2006 18:15:06 + (UTC) writes: Anupam Hi Stephane, Anupam Stéphane CRUVEILLER scruveil at genoscope.cns.fr writes: is there a way to pass a list of patterns to the grep function? I vaguely remember something with

[R] grep function with patterns list...

2006-10-16 Thread Stéphane CRUVEILLER
Dear R-users, is there a way to pass a list of patterns to the grep function? I vaguely remember something with %in% operator... Thanks, Stéphane. -- La science a certes quelques magnifiques réussites à son actif mais à tout prendre, je préfère de loin être heureux plutôt qu'avoir raison.

Re: [R] grep function with patterns list...

2006-10-16 Thread Gabor Grothendieck
Try this: grep(b|c|d, letters, value = TRUE) [1] b c d On 10/16/06, Stéphane CRUVEILLER [EMAIL PROTECTED] wrote: Dear R-users, is there a way to pass a list of patterns to the grep function? I vaguely remember something with %in% operator... Thanks, Stéphane. -- La science a

Re: [R] grep function with patterns list...

2006-10-16 Thread Stéphane CRUVEILLER
Thx for the hint, but what would I have used if b,c and d were values of a dataframe for instance? Stéphane. Gabor Grothendieck a écrit : Try this: grep(b|c|d, letters, value = TRUE) [1] b c d On 10/16/06, Stéphane CRUVEILLER [EMAIL PROTECTED] wrote: Dear R-users, is there a way to pass

Re: [R] grep function with patterns list...

2006-10-16 Thread Stéphane CRUVEILLER
Ooops sorry for html tags... Just forgot to edit the message before sending it... So back to my question: Thx for the hint, but what would I have used if b,c and d were values of a dataframe for instance? X is for instance a dataframe: X Mypatterns 1 pattern1 2 pattern2 3 pattern3 Y

Re: [R] grep function with patterns list...

2006-10-16 Thread Gabor Grothendieck
DF - data.frame(pat = letters[1:3]) grep(paste(DF$pat, collapse = |), letters, value = TRUE) [1] a b c On 10/16/06, Stéphane CRUVEILLER [EMAIL PROTECTED] wrote: Ooops sorry for html tags... Just forgot to edit the message before sending it... So back to my question: Thx for the hint, but

Re: [R] grep function with patterns list...

2006-10-16 Thread Anupam Tyagi
Hi Stephane, Stéphane CRUVEILLER scruveil at genoscope.cns.fr writes: is there a way to pass a list of patterns to the grep function? I vaguely remember something with %in% operator... I think you are looking for the %in% and %nin% which are part of Design package, and also in Hmisc library.

Re: [R] grep question

2006-08-31 Thread jim holtman
This finds the matching indices of Farrah and Common and then create a set that does not include them: x - c('Farrah', 'more', 'Common', 'last') got.F - grep('Farrah',x) got.C - grep('Common', x) not.ForC - setdiff(seq(along=x), c(got.F, got.C)) x[not.ForC] [1] more last On 8/31/06, Bob

Re: [R] grep question

2006-08-31 Thread Gabor Grothendieck
Or using the same x: setdiff(x, grep(Farrah|Common, x, value = TRUE)) [1] more last On 8/31/06, jim holtman [EMAIL PROTECTED] wrote: This finds the matching indices of Farrah and Common and then create a set that does not include them: x - c('Farrah', 'more', 'Common', 'last') got.F -

Re: [R] grep question

2006-08-31 Thread jim holtman
You have to be careful if the strings are embedded: x - c('xxxFarrahxxx' ,'more than last time', 'some Common numbers', 'last one') setdiff(x, grep('Farrah|Common', x)) # not correct [1] xxxFarrahxxxmore than last time some Common numbers last one ForC - grep('Farrah|Common', x)

Re: [R] grep question

2006-08-31 Thread jim holtman
Forget the last reply. I left the 'value=TRUE' off the grep. x - c('xxxFarrahxxx' ,'more than last time', 'some Common numbers', 'last one') setdiff(x, grep('Farrah|Common', x, value=TRUE)) [1] more than last time last one ForC - grep('Farrah|Common', x) x[setdiff(seq(along=x), ForC)] [1]

Re: [R] grep help needed

2005-07-26 Thread John Fox
Dear Denis, I don't believe that anyone fielded your question -- my apologies if I missed a response. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Denis Chabot Sent: Monday, July 25, 2005 9:46 PM To: R list Subject: [R] grep help needed Hi

Re: [R] grep help needed

2005-07-26 Thread Denis Chabot
list Subject: [R] grep help needed Hi, In another thread (PBSmapping and shapefiles) I asked for an easy way to read shapefiles and transform them in data that PBSmapping could use. One person is exploring some ways of doing this, but it is possible I'll have to do this manually

[R] grep help needed

2005-07-25 Thread Denis Chabot
Hi, In another thread (PBSmapping and shapefiles) I asked for an easy way to read shapefiles and transform them in data that PBSmapping could use. One person is exploring some ways of doing this, but it is possible I'll have to do this manually. With package maptools I am able to extract

[R] grep negation

2005-06-23 Thread Marcus Leinweber
hi, using the example in the grep help: txt - c(arm,foot,lefroo, bafoobar) i - grep(foo,txt); i [1] 2 4 but how can i get the negation (1,3) when looking for 'foo'? thanks, m. __ R-help@stat.math.ethz.ch mailing list

Re: [R] grep negation

2005-06-23 Thread james . holtman
: [EMAIL PROTECTED]Subject: [R] grep negation ath.ethz.ch

Re: [R] grep negation

2005-06-23 Thread Dimitris Rizopoulos
://www.student.kuleuven.ac.be/~m0390867/dimitris.htm - Original Message - From: Marcus Leinweber [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Sent: Thursday, June 23, 2005 2:59 PM Subject: [R] grep negation hi, using the example in the grep help: txt - c(arm,foot,lefroo, bafoobar

Re: [R] grep negation

2005-06-23 Thread Don MacQueen
If all you need to do is extract the subset of elements of txt that do not contain 'foo', then txt[-i] will do the job. Provided that at east one element of txt contains 'foo', that is. -Don At 2:59 PM +0200 6/23/05, Marcus Leinweber wrote: hi, using the example in the grep help: txt -

[R] grep

2004-03-12 Thread Ernesto Jardim
Hi, I want to use the first digit of the elements of a vector. I've tried grep but didn't work. Any help is welcome. Thanks EJ grep(^[0-9],as.character(runif(100,0,2))) [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 [19] 19 20 21 22 23 24 25 26 27

Re: [R] grep

2004-03-12 Thread Chuck Cleland
Ernesto Jardim wrote: I want to use the first digit of the elements of a vector. I've tried grep but didn't work. Any help is welcome. substr(as.character(runif(100,0,2)), 1, 1) see ?substr -- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495

Re: [R] grep

2004-03-12 Thread Sundar Dorai-Raj
Ernesto Jardim wrote: Hi, I want to use the first digit of the elements of a vector. I've tried grep but didn't work. Any help is welcome. Thanks EJ grep(^[0-9],as.character(runif(100,0,2))) [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 [19] 19 20 21

Re: [R] grep

2004-03-12 Thread Marc Schwartz
On Fri, 2004-03-12 at 11:08, Ernesto Jardim wrote: Hi, I want to use the first digit of the elements of a vector. I've tried grep but didn't work. Any help is welcome. Thanks EJ grep(^[0-9],as.character(runif(100,0,2))) [1] 1 2 3 4 5 6 7 8 9 10 11 12 13

Re: [R] grep

2004-03-12 Thread Tom Blackwell
Ernesto - Use as.numeric(substr(as.character(x), 1, 1)). - tom blackwell - u michigan medical school - ann arbor - On Fri, 12 Mar 2004, Ernesto Jardim wrote: Hi, I want to use the first digit of the elements of a vector. I've tried grep but didn't work. Any help is welcome.

Re: [R] grep

2004-03-12 Thread Samuelson, Frank*
as.integer(x/10^(as.integer(log10(x -Original Message- From: Ernesto Jardim [mailto:[EMAIL PROTECTED] Sent: Friday, March 12, 2004 12:08 PM To: Mailing List R Subject: [R] grep Hi, I want to use the first digit of the elements of a vector. I've tried grep but didn't work. Any

Re: [R] grep and gsub on backslash and quotes

2003-08-14 Thread Peter Dalgaard BSA
Simon Fear [EMAIL PROTECTED] writes: The following code works, to gsub single quotes to double quotes: line - gsub(', '', line) (that's a single quote within doubles then a double within singles if your viewer's font is not good). But The R Language Manual tells me that Quotes and

[R] grep and gsub on backslash and quotes

2003-08-14 Thread Simon Fear
The following code works, to gsub single quotes to double quotes: line - gsub(', '', line) (that's a single quote within doubles then a double within singles if your viewer's font is not good). But The R Language Manual tells me that Quotes and other special characters within strings are

RE: [R] grep and gsub on backslash and quotes

2003-08-14 Thread Simon Fear
the examples posted will be of as much use to others as they are to me.) Simon -Original Message- From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] Sent: 12 August 2003 17:13 To: Simon Fear Cc: [EMAIL PROTECTED] Subject: Re: [R] grep and gsub on backslash and quotes Security

Re: [R] grep and gsub on backslash and quotes

2003-08-14 Thread Prof Brian Ripley
On Tue, 12 Aug 2003, Simon Fear wrote: The following code works, to gsub single quotes to double quotes: line - gsub(', '', line) (that's a single quote within doubles then a double within singles if your viewer's font is not good). But The R Language Manual tells me that Quotes