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
seWithin(data = NULL, measurevar, betweenvars = NULL, withinvars = NULL, idvar = NULL, na.rm = TRUE, conf.interval = 0.95, shownormed = FALSE)
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 |
A data.table
Code adapted from R cookbook (see references).
http://www.cookbook-r.com/Graphs/Plotting_means_and_error_bars_(ggplot2)/
Hause Lin
result <- seWithin(data = ChickWeight, measurevar = "weight", betweenvars = "Diet", withinvars = "Time", idvar = "Chick")#>#>#>#>#> Confidence intervals: 0.95#># 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")#>#>#>#>#> Confidence intervals: 0.95#>#>#>#>#> Confidence intervals: 0.95#>