TABLE OF CONTENTS


miscUtils/submean [ Functions ]

NAME

    submean --- compute the mean of a subset of a vector

FUNCTION

For a vector or matrix x and a subset, compute the mean of the subset of values of x.

SYNOPSIS

1173 submean <- function(x, subset, f = mean) 

INPUTS

    x          a vector or matrix
    subset     a subset, either as a range or as logical
    f          a function to be applied (mean by default)

OUTPUTS

    The function f applied to a subset of x

SOURCE

1176 {
1177     if(is.null(x)) return(NULL)
1178     if(!is.null(dim(x))) return(apply(x[subset, ,drop = F], 2, f))
1179     else return(f(x[subset]))
1180 }