Skip to content

Excluding NAs from round correlation

4 messages · Weidong Gu, Julie

#
Hello,
I am quite new to R and I am trying to get a round correlation from a table
with dozens of columns. However, all the columns contain several blank
places which show to me as NAs. Then, when I type round(cor(data),2), I get
no results - everything (except correlation of one column with the same one,
of course) is NA.
I do not want to replace NA with zero, because it would ruin the results. I
just want R "not to look at NA" and correlate just places with numbers. Is
it possible?
Thank you very much for help!

--
View this message in context: http://r.789695.n4.nabble.com/Excluding-NAs-from-round-correlation-tp3741296p3741296.html
Sent from the R help mailing list archive at Nabble.com.
#
check

?cor

Please note the parameter 'use'

Weidong Gu
On Sat, Aug 13, 2011 at 9:06 AM, Julie <julie.novakova at gmail.com> wrote:
#
Thank you, I found this in the help pack:

use: an optional character string giving a method for computing covariances
in the presence of missing values. This must be (an abbreviation of) one of
the strings "everything", "all.obs", "complete.obs", "na.or.complete", or
"pairwise.complete.obs"

I should probably use "na.or.complete" when I want to get results not saying
NA, is it right?

--
View this message in context: http://r.789695.n4.nabble.com/Excluding-NAs-from-round-correlation-tp3741296p3741924.html
Sent from the R help mailing list archive at Nabble.com.
#
The help pack says:

use: an optional character string giving a method for computing covariances
in the presence of missing values. This must be (an abbreviation of) one of
the strings "everything", "all.obs", "complete.obs", "na.or.complete", or
"pairwise.complete.obs"

If I used "everything", the results would be NAs again. "all.obs" would
result in error. "complete.obs" gives me error too. "na.or.complete" gives
me all NAs... But "pairwise.complete.obs" finally got the right results.

--
View this message in context: http://r.789695.n4.nabble.com/Excluding-NAs-from-round-correlation-tp3741296p3742039.html
Sent from the R help mailing list archive at Nabble.com.