Skip to content
Back to formatted view

Raw Message

Message-ID: <4329A1EF.26591.19498C8@localhost>
Date: 2005-09-15T14:31:43Z
From: PIKAL Petr
Subject: Remove vector elements from another vector
In-Reply-To: <BAY12-F51E657A81E8BED92ECA0DDD9C0@phx.gbl>

Hi

On 13 Sep 2005 at 14:35, Karsten Luder wrote:

> Hello,
> 
> I have two vectors of different lengths. Fx a <- 1:9; b <- c(4, 5).
> What is the best way to remove the elements in vector b from vector a
> so that the result would be a vector with elements c(1,2,3,6,7,8,9)?

> which(!a%in%b)
[1] 1 2 3 6 7 8 9
> a[which(!a%in%b)]
[1] 1 2 3 6 7 8 9
> a[(!a%in%b)]
[1] 1 2 3 6 7 8 9
>


HTH
Petr

> 
> Best regards,
> Kalle
> 
> _________________________________________________________________ Find
> masser af gode tilbud p?? MSN Shopping http://shopping.msn.dk/
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html

Petr Pikal
petr.pikal at precheza.cz