I think you want %in%
subpool %in% pool
pool %in% subpool
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and
Forest
team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium
+ 32 2 525 02 51
+ 32
Hello Duncan,
Thanks for this!
This works!
Best,
Rebecca
-Original Message-
From: Duncan Murdoch [mailto:murdoch.dun...@gmail.com]
Sent: Wednesday, January 23, 2013 11:23 AM
To: Yuan, Rebecca
Cc: R help
Subject: Re: [R] to check if a character string is in a group of character
Not sure what you want this for, but work along the following:
> pool = c("s1","s2")
> subpool = c("s1")
> ifelse(pool==subpool,1,0)
[1] 1 0
Notice:
> pool2 = c("s2","s1")
> ifelse(pool2==subpool,1,0)
[1] 0 1
Etc.
Hope this helps.
José
José Iparraguirre
Chief Economist
Age UK
-Origin
On 13-01-23 11:14 AM, Yuan, Rebecca wrote:
Hello,
How can I judge if a string is in a group of string? For example, I would like
to have
if (subpool in pool){
}else{
}
if (subpool %in% pool)
Duncan Murdoch
Where
pool = c("s1","s2")
subpool = c("s1")
How can I write the "subpool in po
4 matches
Mail list logo