[R] function

Jeff Gentry jgentry at jimmy.harvard.edu
Wed Feb 19 04:09:04 CET 2003


On Wed, 19 Feb 2003 skayis at lic.co.nz wrote:
> The following function:
> match(myvec,myscaler)!="NA"
> I need a return
> FALSE  FALSE TRUE TRUE TRUE TRUE TRUE   FALSE FALSE ...FALSE
> Is there any function to perform this?

Try: 

myvec == myscaler

> z <- c(24, 24, 10, 10, 10, 10, 44, 44, 44, 45, 45, 45, 54, 54, 54, 54,
42, 42)> a <- 10
> match(z,a)
 [1] NA NA  1  1  1  1 NA NA NA NA NA NA NA NA NA NA NA NA
> which(z == a)
[1] 3 4 5 6
> z == a
 [1] FALSE FALSE  TRUE  TRUE  TRUE  TRUE FALSE FALSE FALSE FALSE FALSE
FALSE
[13] FALSE FALSE FALSE FALSE FALSE FALSE

-J




More information about the R-help mailing list