[R] Search a string inside a data.frame
petr.pikal at precheza.cz
Wed Dec 21 10:19:27 CET 2011
> Dear all,
> I have a string and I want to search for its existance inside a
> (or in a column of the data.frame).
> One way is for me to do this manually: Make a for loop for the number of
> elements and compare one by one element. Is there though any more
> way to do that?
Rather vague question. What kind of string? Shall it be matched fully?
sapply(your.data.frame, match, "your.string", nomatch=0)
gives you a result 1 where it matches the string and 0 where not.
> [[alternative HTML version deleted]]
> R-help at r-project.org mailing list
> PLEASE do read the posting guide
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help