Mean Value (Arithmetic Average)

DESCRIPTION:

Returns a number which is the mean of the data. A fraction to be trimmed from each end of the ordered data can be specified.

USAGE:

mean(x, trim = 0, na.rm = F, weights=NULL) 

REQUIRED ARGUMENTS:

x
numeric object or bdNumeric. Missing values (NA) are allowed.

OPTIONAL ARGUMENTS:

trim
fraction (between 0 and .5, inclusive) of values to be trimmed from each end of the ordered data. If trim >= .5 the result is the median.
na.rm
logical flag; indicates whether missing values should be removed before computation.
weights
vector the same length as x. If present a weighted mean is returned, sum(weights * x) / sum(weights) (after weights are modified to reflect trimming).

VALUE:

(trimmed) mean of x.

DETAILS:

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".

REFERENCES:

Hoaglin, D. C., Mosteller, F. and Tukey, J. W., editors (1983). Understanding Robust and Exploratory Data Analysis. Wiley, New York.

SEE ALSO:

, , , , , , .

EXAMPLES:

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