[R] how to ignore NA with "NA" or "NULL"

jeff6868 geoffrey_klein at etu.u-bourgogne.fr
Tue Jun 5 11:54:23 CEST 2012


Thanks again but my errors are still here. Is it maybe coming from the next
fonction (I combinate these 2 functions but I thought it was coming from the
first one):

process.all <- function(df.list, mat){
        
        f <- function(station)
             na.fill(df.list[[ station ]], df.list[[ max.cor[station] ]])
                         
        g <- function(station){
        x <- df.list[[station]]
        if(any(is.na(x[1:8700,1]))){
            mat[row(mat) == col(mat)] <- -Inf
            nas <- which(is.na(x[1:8700,1]))
            ord <- order(mat[station, ], decreasing = TRUE)[-c(1,
ncol(mat))]
            for(y in ord){                           
                if(all(!is.na(df.list[[y]][1:8700,1][nas]))){
                    xx <- df.list[[y]][1:8700,1]
                    new <- data.frame(xx=xx)
                    x[1:8700,1][nas] <- predict(lm(x[1:8700,1]~xx,
na.action=na.exclude), new)[nas]
                    break
                }
            }
        }
        x
    }             
        
        n <- length(df.list)
        nms <- names(df.list)
        max.cor <- sapply(seq.int(n), get.max.cor, corhiver2008capt1)
        df.list <- lapply(seq.int(n), f)
        df.list <- lapply(seq.int(n), g)
        names(df.list) <- nms
        df.list
    }

    refill <- process.all(lst, corhiver2008capt1)
    refill <- as.data.frame(refill)

The error is when "refill" is created. It applies "process.all" in which
"na.fill" is also used. Do you see perhaps any error or missing code which
could create this NA problem when I introduce "only NAs" files?

--
View this message in context: http://r.789695.n4.nabble.com/how-to-ignore-NA-with-NA-or-NULL-tp4632287p4632388.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list