Learn R Programming

sjstats (version 0.10.2)

mn: Sum, mean and median for vectors

Description

mn(), md() and sm() calculate the mean, median or sum of values in a vector, but have set argument na.rm to TRUE by default.

Usage

mn(x, na.rm = TRUE)

sm(x, na.rm = TRUE)

md(x, na.rm = TRUE)

Arguments

x

A vector.

na.rm

Logical, whether to remove NA values from x before computing mean, median or sum.

Value

The mean, median or sum of x.

Examples

Run this code
# NOT RUN {
data(efc)
md(efc$neg_c_7)
mn(efc$neg_c_7)
mean(efc$neg_c_7)
sm(efc$neg_c_7 > 15)

# }

Run the code above in your browser using DataLab