Skip to content
Back to formatted view

Raw Message

Message-ID: <da79af330803091635t1765b672h67068e716dc73e57@mail.gmail.com>
Date: 2008-03-09T23:35:25Z
From: Henrique Dallazuanna
Subject: question about matrix one column values matching a vector of values
In-Reply-To: <8ee9d8f20803091622x6cbdc501q9a1ea8df2339879b@mail.gmail.com>

Use %in% indeed of '=='

a[a[,1] %in% b,]


On 09/03/2008, Waverley <waverley.paloalto at gmail.com> wrote:
> Hi,
>
> I have a matrix
> a = matrix (1:16, 4, 4)
> b = c (2,3)
>
> I want to find out which rows of a, where a[,1] equals any values of b?
>
> I know that if b is only one value, e.g, b=2, then what I want is a[a[,1] ==
> 2,]
>
> But what about if it is not one value but a vector of values?
>
> Thanks much in advance.
>
> --
> Waverley @ Palo Alto
>
> ______________________________________________
> 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.
>


-- 
Henrique Dallazuanna
Curitiba-Paran?-Brasil
25? 25' 40" S 49? 16' 22" O