Below is one way to do this:
>
v1<-c(2,2,4,NA,NA,NA,10,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA)
>
v2<-c(NA,4,NA,NA,NA,NA,10,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,100,NA)
> length(v1)
[1] 20
> length(v2)
[1] 20
> intersect(which(!is.na(v1)),which(!is.na(v2)))
[1] 2 7
>
--- dxc13 <[EMAIL PROTECTED]> wro
useR's
I am trying to compare two vectors that have the same length. More
specifically, I am interested in comparing the corresponding positions of
each element in the vector.
Consider these two vectors of length 20:
v1 <- 224NA NA NA 10 NA NA NA NA NA NA NA NA NA NA
Here is one way of doing it:
> v1
[1] 1 1 NA NA 1 NA NA NA NA 1 1 1 NA 1 NA 1 NA NA 1 NA
> v2
[1] NA 1 NA 1 1 1 1 1 NA 1 1 NA 1 1 NA NA NA 1 NA 1
> which(!(is.na(v1) | is.na(v2)))
[1] 2 5 10 11 14
>
On 9/17/07, dxc13 <[EMAIL PROTECTED]> wrote:
>
> useR's
>
> I am trying
3 matches
Mail list logo