I tried your function. It works great thanks. I used then diag() in order to
have the value "1" for the whole diagonal of my matrix. But it still doesn't
work it's crazy.
By deleting colums and rows (and so some files) containing only NAs in the
correlation matrix, it doesn't work when I apply
Try this.
check.na <- function(mat){
nas <- NULL
for(st in seq.int(ncol(mat)))
if(sum(is.na(mat[, st])) == nrow(mat) - 1) nas <- c(nas, st)
if(length(nas)){
mat <- mat[, -nas]
mat <- mat[-nas, ]
}
mat
}
Hello,
Maybe the function could return a special value, such as zero.
Since a column with that number doesn't exist, the code executed afterward
would simply move on to the second greatest correlation.
The function would then become
get.max.cor <- function(station, mat){
mat[row(mat) == col
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
Hi Jim,
Thanks for your answer.
I tried your proposition. The idea seems to be good but I still have my
error.
Actually, the error is in the next function, which uses the function
get.max.cor I told you before.
I also tried these 2 functions with data containing no missing data, and it
works well.
On 05/21/2012 05:59 PM, jeff6868 wrote:
Hi everybody,
I have a small question about R.
I'm doing some correlation matrices between my files. These files contains
each 4 columns of data.
These data files contains missing data too. It could happen sometimes that
in one file, one of the 4 columns c
Hi everybody,
I have a small question about R.
I'm doing some correlation matrices between my files. These files contains
each 4 columns of data.
These data files contains missing data too. It could happen sometimes that
in one file, one of the 4 columns contains only missing data NA. As I'm
doing
7 matches
Mail list logo