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? Thanks again, Paul -- View this message in context: http://n4.nabble.com/use-logical-in-cor-test-tp1744701p1744896.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ 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.