R/getmeans.R

Defines functions getmeans

Documented in getmeans

getmeans <-
function(data, factors)
{
    groups <- levels(as.factor(factors))
    means <- array(NA, c(length(groups), dim(data)[2]))
    for(i in 1:length(groups))
        means[i,] <- apply(data[factors == groups[i], , drop = FALSE], 2, mean)
    colnames(means) <- colnames(data)
    return(means)
}

Try the dawai package in your browser

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

dawai documentation built on Jan. 20, 2018, 9:22 a.m.