se: Calculate standard error of the mean.

Description Usage Arguments Value See Also Examples

View source: R/util.R

Description

Calculate standard error of the mean.

Usage

1
se(x, na.rm = FALSE)

Arguments

x

A vector.

na.rm

Logical: whether or not to remove NA values (default set to FALSE - including NAs).

Value

Standard Error of the mean.

See Also

Other Utility functions: findAbsMin(), find_n_neighbors(), firstLetterCap(), getArrowPos(), getDec(), getRange(), getRatioCoords(), get_palette(), group_sort(), inch2coords(), isColor(), list2str(), move_n_point(), orderBoxplot(), sortGroups()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
# load example data:
data(chickwts)
str(chickwts)

# first calculate means per feeding type:
avg <- with(chickwts, tapply(weight, list(feed), mean))
par(cex=1.25)
b <- barplot(avg, beside=TRUE, names.arg=FALSE, ylim=c(0,450))
text(b, rep(0, length(b)), labels=names(avg), srt=90, adj=-.25)

# calculate mean collapsing over feeding types:
abline(h=mean(avg), lwd=1.5, col='red1')
# add SE reflecting variation between feeding types:
abline(h=mean(avg)+c(-1,1)*se(avg), lty=2, col='red1')
text(getCoords(.5), mean(avg)+se(avg), 
    labels=expression('mean' %+-% '1SE'), pos=3, col='red1')

# Note that SE makes more sense for experiments with 
# different groups or participants.

plotfunctions documentation built on April 28, 2020, 5:10 p.m.