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)

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

References

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

See also

Author

Hause Lin

Examples

result <- seWithin(data = ChickWeight, measurevar = "weight", betweenvars = "Diet", withinvars = "Time", idvar = "Chick")
#> Automatically converting the following non-factors to factors: Time
#> Joining, by = c("Chick", "Diet")
#> Joining, by = c("Diet", "Time", "N")
#> Factors have been converted to characters.
#> 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")
#> Automatically converting the following non-factors to factors: Time
#> Joining, by = c("Chick", "Diet")
#> Joining, by = c("Diet", "Time", "N")
#> Factors have been converted to characters.
#> Confidence intervals: 0.95
#>
#> Joining, by = c("Chick", "Diet")
#> Joining, by = c("Diet", "Time", "N")
#> Factors have been converted to characters.
#> Confidence intervals: 0.95
#>