Re: [R] Matching Problem: Want to match to data.frame with inexact matching identifier (one identifier has to be in the range of the other).

2011-04-19 Thread Christoph Jäckel
Hi together, I found a solution to my problem that works for me and performs reasonable well in my opinion. Instead of looping through both datasets, I decided to replicate each row in d2 from Min_Month to Max_Month and then use the match-function. Here is the code (I changed the original example

[R] Matching Problem: Want to match to data.frame with inexact matching identifier (one identifier has to be in the range of the other).

2011-04-16 Thread Christoph Jäckel
Hello R-Community, I have the following matching problem: I have two data.frames, one with an observation every month (per company ID), and one with an observation every quarter (per company ID; note that quarter means fiscal quarter; therefore 1Q = Jan, Feb, Mar is not necessarily correct and als

Re: [R] Matching Problem

2010-02-23 Thread Newbie19_02
Dear Dennis, Thanks the a[a %n% b] function worked well for me. THanks, for the help, Natalie -- View this message in context: http://n4.nabble.com/Matching-Problem-tp1565841p1565910.html Sent from the R help mailing list archive at Nabble.com. __ R

[R] Matching Problem

2010-02-23 Thread Newbie19_02
Hi, I have a problem with function match. I might not be using it properly? I have two character vectors that contain a unique identifier: gtype_prochi <- ("CAO1524452" "CAO0966182" "CAO9209719" "CAO4436178" "CAO3761898" "CAO3529266" "CAO2427148" "CAO8829776" "CAO2517174" "CAO5371418" "CAO1535

Re: [R] matching problem

2008-08-06 Thread Gabor Grothendieck
On Wed, Aug 6, 2008 at 9:01 AM, Tom.O <[EMAIL PROTECTED]> wrote: > > I have a matching problem that I cant solve. > mystring = "xxx{XX}yy{YYY}zzz{Z}" where "x","X","y","Y","z","Z" basiclly can > be anything, letters, digits etc. I'm only interested in the content within > each "{}". > > I am close

Re: [R] matching problem

2008-08-06 Thread Henrique Dallazuanna
One option is: strapply(mystring, "\\{[^\\}]+" , function(x)gsub("\\{", "", x), perl = F) On Wed, Aug 6, 2008 at 10:01 AM, Tom.O <[EMAIL PROTECTED]> wrote: > > I have a matching problem that I cant solve. > mystring = "xxx{XX}yy{YYY}zzz{Z}" where "x","X","y","Y","z","Z" basiclly can > be anything

[R] matching problem

2008-08-06 Thread Tom.O
I have a matching problem that I cant solve. mystring = "xxx{XX}yy{YYY}zzz{Z}" where "x","X","y","Y","z","Z" basiclly can be anything, letters, digits etc. I'm only interested in the content within each "{}". I am close but not really there yet. library(gsubfn) strapply(mystring,"\\{[^\\}]+",, p

Re: [R] matching problem

2008-06-27 Thread Gabor Grothendieck
Here is a solution using strapply from the gsubfn package: library(gsubfn) strapply(myexstrings, "(\\w+).*", backref = -1, simplify = c) It matches the first string of word characters following by anything else and then returns the first backreference in each match, i.e. the portion within parent

Re: [R] matching problem

2008-06-27 Thread Tom.O
Thanks guys, all of you. You have just made this weekend a much more happier weekend. Regards Tom Hans-Jörg Bibiko wrote: > > > On 27 Jun 2008, at 13:56, Tom.O wrote: > >> >> Well I have tried that and it's unfortuanally not the solution. >> This return all the characters in the string, but

Re: [R] matching problem

2008-06-27 Thread Hans-Joerg Bibiko
On 27 Jun 2008, at 13:56, Tom.O wrote: Well I have tried that and it's unfortuanally not the solution. This return all the characters in the string, but I dont want the characters after the ending non-character symbol. Only the starting characters ore of interest. gsub("\\W*","", myexst

Re: [R] matching problem

2008-06-27 Thread Daniel Folkinshteyn
this should do what you want: > myexstrings = c("*AAA.AA","BBB BB","*.CCC.","**dd- d") > a = gsub("^\\W*","", myexstrings,perl=T) > b = gsub("\\W.*", "", a, perl=T) > b [1] "AAA" "BBB" "CCC" "dd" first one, removes any non-word characters from the beginning (as you already figured out) second o

Re: [R] matching problem

2008-06-27 Thread Tom.O
Well I have tried that and it's unfortuanally not the solution. This return all the characters in the string, but I dont want the characters after the ending non-character symbol. Only the starting characters ore of interest. > gsub("\\W*","", myexstrings,perl=T) [1] "A" "B" "CCC" "ddd"

Re: [R] matching problem

2008-06-27 Thread Hans-Joerg Bibiko
On 27 Jun 2008, at 12:23, Tom.O wrote: Hi R gurus I have a matching problem that I cant solve. I have tried multiple solutions and searched varius help-sites but I cant get it to work. This is the problem myexstrings = c("*AAA.AA","BBB BB","*.CCC.","**dd- d") what I want do do is to remov

[R] matching problem

2008-06-27 Thread Tom.O
Hi R gurus I have a matching problem that I cant solve. I have tried multiple solutions and searched varius help-sites but I cant get it to work. This is the problem myexstrings = c("*AAA.AA","BBB BB","*.CCC.","**dd- d") what I want do do is to remove any non-characters in the beginning and ever

Re: [R] Matching Problem

2008-02-12 Thread Bill.Venables
819 4402 Home Phone: +61 7 3286 7700 mailto:[EMAIL PROTECTED] http://www.cmis.csiro.au/bill.venables/ -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Tom.O Sent: Tuesday, 12 February 2008 8:44 PM To: r-help@r-project.org Subject: [R]

Re: [R] Matching Problem

2008-02-12 Thread jim holtman
Here is one way of doing it: > MyData <- c("Test1","Test2","I(Test1^2)","I(Test2^3)","I(Test1.Test2^2)") > x <- gsub("^(.*\\(|)([^^)]*|.*).*", "\\2", MyData) > x [1] "Test1" "Test2" "Test1" "Test2" "Test1.Test2" > unique(x) [1] "Test1" "Test2" "Test1.Test2" >

Re: [R] Matching Problem

2008-02-12 Thread Søren Højsgaard
uot;^I\\((.*)\\^.+", "\\1\\", MyData) [1] "Test1" "Test2" "Test1" "Test2" "Test1.Test2" Now use unique on the result. Regards Søren Fra: [EMAIL PROTECTED] på vegne af T

Re: [R] Matching Problem

2008-02-12 Thread Benilton Carvalho
unique(gsub("^.*\\((.+)\\^.*", "\\1", MyData)) ? b On Feb 12, 2008, at 5:44 AM, Tom.O wrote: Hi I have this vector of strings. MyData <- c("Test1","Test2","I(Test1^2)","I(Test2^3)","I(Test1.Test2^2)") where I want to extract only the text after "I(" and before "^" so that the string re

Re: [R] Matching Problem

2008-02-12 Thread Henrique Dallazuanna
Maybe: all.vars(parse(text=paste(MyData, collapse="+"))) On 12/02/2008, Tom.O <[EMAIL PROTECTED]> wrote: > > Hi > > I have this vector of strings. > > MyData <- c("Test1","Test2","I(Test1^2)","I(Test2^3)","I(Test1.Test2^2)") > where I want to extract only the text after "I(" and before "^" so th

Re: [R] Matching Problem

2008-02-12 Thread Gabor Grothendieck
See this post: https://stat.ethz.ch/pipermail/r-help/2008-February/153819.html as well as the rest of that thread. On Feb 12, 2008 5:44 AM, Tom.O <[EMAIL PROTECTED]> wrote: > > Hi > > I have this vector of strings. > > MyData <- c("Test1","Test2","I(Test1^2)","I(Test2^3)","I(Test1.Test2^2)") > w

[R] Matching Problem

2008-02-12 Thread Tom.O
Hi I have this vector of strings. MyData <- c("Test1","Test2","I(Test1^2)","I(Test2^3)","I(Test1.Test2^2)") where I want to extract only the text after "I(" and before "^" so that the string returned only contain c("Test1","Test2","Test1.Test2") I am not very skilled in the use of matching patt