[R] to check if a character string is in a group of character strings

2013-01-23 Thread Yuan, Rebecca
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{ } Where pool = c(s1,s2) subpool = c(s1) How can I write the subpool in pool right in R? Thanks very much! Cheers, Rebecca

Re: [R] to check if a character string is in a group of character strings

2013-01-23 Thread Duncan Murdoch
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 pool

Re: [R] to check if a character string is in a group of character strings

2013-01-23 Thread Jose Iparraguirre
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 -Original

Re: [R] to check if a character string is in a group of character strings

2013-01-23 Thread Yuan, Rebecca
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

Re: [R] to check if a character string is in a group of character strings

2013-01-23 Thread ONKELINX, Thierry
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