Saturday, 15 March 2014

r - how can we force our code to calculate correlation when P is less than 0.05? -



r - how can we force our code to calculate correlation when P is less than 0.05? -

i using code below calculate correlation map between 2 datasets . code worked fine , got results like:![enter image description here]![enter image description here][1].

dir1 <- list.files("d:thly", "*.bin", full.names = true) dir2 <- list.files("d:002", "*.envi", full.names = true) file_tot <- array(dim = c(1440, 720, 11, 2)) }

i calculate correlation when ``. thought on how this?

you question isn't (i.e. not @ all) reproducible, should started. trick calculate correlations, plot/return ones above threshold. function cor.test performs correlation test.

return_cor = function(x, y) { z = cor.test(x,y) if(z[[3]] < 0.05) { return(z[[4]]) } else { return(na) } }

and test:

x = rnorm(10); y = rnorm(10) r> return_cor(x, x) cor 1 r> return_cor(x, y) [1] na

so

resultsr = apply(file_tot, c(1,2), function(x) {return_cor(x[,1],x[,2])})

r correlation

No comments:

Post a Comment