mean(x, trim = 0, na.rm = F, weights=NULL)
bdNumeric.
Missing values (NA) are allowed.
0 and
.5, inclusive) of values to be trimmed from
each end of the ordered data.
If
trim >= .5 the result is the median.
x. If present
a weighted mean
is returned,
sum(weights * x) / sum(weights)
(after weights are modified to reflect trimming).
If
x contains any
NAs, the result is
NA unless
na.rm=TRUE.
If
x is a factor or
bdFactor, a warning is generated and the result is
NA.
When
trim is positive, approximately
trim*length(x) largest values
and
trim*length(x) smallest values are ignored; the mean of the
remaining values is returned.
When
trim=.25, the result is often called the "midmean".
Hoaglin, D. C., Mosteller, F. and Tukey, J. W., editors (1983). Understanding Robust and Exploratory Data Analysis. Wiley, New York.
algebra <- testscores[,3] # vector of 25 algebra testscores mean(algebra) # Computes the average mean(algebra, trim = .1) # Computes the 10% trimmed mean of scores apply(testscores, 2, mean) # vector of the means of the columns of scores