[R] Find strings in a array
Stephen C. Upton
upton at mitre.org
Sat Feb 8 21:20:04 CET 2003
Francisco,
Is this what you're looking for?
> aa
[1] "ab" "cd" "de" "aa"
> bb
[1] "ab" "cd" "de" "df" "gg" "FF"
> bb %in% aa
[1] TRUE TRUE TRUE FALSE FALSE FALSE
> aa %in% bb
[1] TRUE TRUE TRUE FALSE
OR
> match(aa,bb)
[1] 1 2 3 NA
> match(bb,aa)
[1] 1 2 3 NA NA
If you have a string pattern, then you might also want to take a look at
grep .
HTH
steve
Francisco do Nascimento Junior wrote:
> I need to know which strings of an array that are in another array.
> What a best solution?
>
> Tks,
> Francisco.
>
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> Francisco Júnior,
> Computer Science - UFPE-Brazil
> "One life has more value that the
> world whole"
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> http://www.stat.math.ethz.ch/mailman/listinfo/r-help
More information about the R-help
mailing list