On 2010-03-30 2:41, pgseye wrote:

Thanks for the replies.

In response to Erik:
What does
Both[,1]
show you?

Both[,1]
    [1] 3.36   NA   NA   NA   NA   NA   NA 3.92 3.50   NA   NA   NA   NA 3.76
3.19 3.83   NA 3.66..........

What does
Both[,1]>  2.5
show you?

Both[,1]>2.5
    [1]  TRUE    NA    NA    NA    NA    NA    NA  TRUE  TRUE    NA    NA
NA    NA  TRUE  TRUE........


I understand a logical variable is binary, but don't know how to select a
subset of the data (have tried the subset function, but can't seem to get it
to work)

Bill, when I run what you suggested, I get:

tBoth<- Both
is.na(tBoth[tBoth>  2.5])<- TRUE
Error in is.na(tBoth[tBoth>  2.5])<- TRUE :
   NAs are not allowed in subscripted assignments
R<- cor(tBoth, use = "complete.obs")
R[1,2]
[1] 0.7750889

Any idea with the error message?

This happens because your 'Both' already has missing values.
You can replace the line

 is.na(tBoth[tBoth > 2.5]) <- TRUE

with

 tBoth[tBoth > 2.5] <- NA

and the rest should work.


Thanks again,

Paul

--
Peter Ehlers
University of Calgary

______________________________________________
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