On Thu, Jul 24, 2008 at 04:45:14PM +0200, Kunzler, Andreas wrote:
> Hy Richie, thank you for the quick response.
> 
> Unfortunately my problems hold on.
> 
> Once again: 2 vectors (numeric) including NAs 
> My intention: I want to replace the values of vector a that are smaller
> than 2 and larger than 3 into NAs only in case vector b equals 1
> 
> a <- c(rep(seq(1,4),4),NA,NA)
> b <- c(rep(seq(1,2),7),NA,NA,1,2)

Andreas,

what is wrong with 

a[ (a < 2 | a > 3) & b==1 ] <- NA

? Isn't this what you want?

Btw. I assume you mean replacing values that are either smaller than
2 _OR_ larger than 3, no number is smaller than 2 _AND_ larger than 3,
at least if we consider the usual ordering on numbers.

Best,
Gabor

[...]

-- 
Csardi Gabor <[EMAIL PROTECTED]>    UNIL DGM

______________________________________________
R-help@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.

Reply via email to