Re: [R] Find characters in a matrix and return a TRUE-FALSE vector

From: Jorge Ivan Velez <jorgeivanvelez_at_gmail.com>
Date: Wed, 13 Apr 2011 10:32:33 -0400

Hi Nina,

You might try

sapply(yourdata, function(x) any(x == "C"))

See ?sapply for more details.

HTH,
Jorge

On Wed, Apr 13, 2011 at 7:17 AM, Vitrifizierung <> wrote:

> I have the following problem:
>
> My data is a matrix of multiple columns and rows. The column I am
> interested
> in looks like that (I think it is a column in a matrix that contains a
> vector each?):
>
> [[1]]
> [1] A B C
> [4] D E
>
> [[2]]
> [1] A D E
>
> [[3]]
> [1] C E F
> [4] G
>
> I now want to look for a special word (for example C; in my case the single
> entries are words, not single letters) and return a vector, like
>
> [1] TRUE FALSE TRUE
>
> Is there an easy way to do it?
> Sorry, I am really a beginner and I did not really solve the problem by
> looking into other threads...
>
> Thanks a lot,
> Nina
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Find-characters-in-a-matrix-and-return-a-TRUE-FALSE-vector-tp3446868p3446868.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

        [[alternative HTML version deleted]]



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Wed 13 Apr 2011 - 14:43:30 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 13 Apr 2011 - 14:50:29 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive