R/impute_median.R

Defines functions impute_median

impute_median <-
function(ma, med){
    ma <- t(apply(ma, 1, function(ma) ifelse(is.na(ma), 
    median(ma, na.rm = TRUE), ma)))
    ma[is.na(rowSums(ma)) == TRUE,] <-
    med[is.na(rowSums(ma)) == TRUE]
    return(ma)
}
chronchi/simpleTTMap documentation built on May 12, 2020, 12:38 p.m.