seWithin: Compute standard errors (within-subjects)

seWithinR Documentation

Compute standard errors (within-subjects)

Description

seWithin is used to compute the standard error(s) for one or more variables, for one or more groups in a dataframe, handling within-subjects variables by removing inter-subject variability

Usage

seWithin(data = NULL, measurevar, betweenvars = NULL, withinvars = NULL,
idvar = NULL, na.rm = TRUE, conf.interval = 0.95, shownormed = FALSE)

Arguments

data

a dataframe

measurevar

the name(s) of column(s) that contain the variable to be summariezed

betweenvars

a vector containing names of columns that are between-subjects variables

withinvars

a vector containing names of columns that are within-subjects variables

idvar

the name of the column that identifies each subject

na.rm

boolean that indicates whether to ignore NA's

conf.interval

confidence interval range

shownormed

whether to show noramlized results

Value

A data.table

Note

Code adapted from R cookbook (see references).

Author(s)

Hause Lin

References

http://www.cookbook-r.com/Graphs/Plotting_means_and_error_bars_(ggplot2)/

See Also

stderror

stderror

Examples

result <- seWithin(data = ChickWeight, measurevar = "weight",
betweenvars = "Diet", withinvars = "Time", idvar = "Chick")

# multiple outcome variables
ChickWeight2 <- ChickWeight
ChickWeight2$weight2 <- ChickWeight2$weight * 100 # create a new outcome variable
result <- seWithin(data = ChickWeight2, measurevar = c("weight", "weight2"),
betweenvars = "Diet", withinvars = "Time", idvar = "Chick")

hauselin/hausekeep documentation built on Feb. 3, 2023, 3:09 p.m.