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
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
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
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
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
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
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
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
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"
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
> sub("^I\\((.*)\\^.*$", "\\1", MyData)
[1] "Test1" "Test2" "Test1" "Test2"
"Test1.Test2"
In this case, there is a simple way of discovering which variable names
are present, though
> all.vars(parse(text = MyData))
[1] "Test1" "Test2" "Test1.Test2"
Bill Venables
C
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"
>
A way to do it is to use groups (in perl terminology) in connection with
regular expressions. My (limited) understanding of it is as follows: Consider
> s <-"BBBEEE"
> gsub("BBB(.*)EEE(.*)", "\\1AAA\\2\\", s)
[1] "AAA"
>
The terms in the parentheses are groups which you
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
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
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
16 matches
Mail list logo