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)
}

Try the TTMap package in your browser

Any scripts or data that you put into this service are public.

TTMap documentation built on Nov. 8, 2020, 7:30 p.m.