[R] Prevent calculation when only NA

jeff6868 geoffrey_klein at etu.u-bourgogne.fr
Mon May 21 12:10:19 CEST 2012


Hello Rui,

Thanks for your answer too.
I tried your proposition too, but by giving the value 0 for this file, it
still wants to make a calculation with it. As it is looking for the best
correlation, and then the 2nd best correlation, giving only 0 seems to be a
problem for the 2nd best correlation at least.
Maybe the best way to solve the problem would be to introduce in the
function get.max.cor a line which would delete all the colums containing
only NAs in my correlation matrix? 
For example if my calculated correlation matrix is (imagine that the numeric
values are correlation coefficients for the example):

x <- data.frame(a = 1:10, b = c(1:5,NA,7:9, NA), c = 21:30, d = NA)

Maybe is it possible in my function to delete only columns containing 100%
of NA, in order to have a matrix like this:

 x <- data.frame(a = 1:10, b = c(1:5,NA,7:9, NA), c = 21:30)

and to keep other columns even if there're some NAs (the calculation is
still possible as they're numeric coefficients in the column).
Actually, it cannot look for the best or the second best correlation
coefficient in a column if it contains only NA.
I think that a correlation matrix like this would allow the calculation for
the next function and the rest of my script.

--
View this message in context: http://r.789695.n4.nabble.com/Prevent-calculation-when-only-NA-tp4630716p4630731.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list