se is used to compute the standard error(s) for one or more variables, for one or more groups in a dataframe.

stderror(data = NULL, measurevar, groupvars = NULL,
na.rm = TRUE, conf.interval = 0.95, tonumeric = TRUE)

Arguments

data

a dataframe

measurevar

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

groupvars

a vector containing names of columns that contain grouping variables

na.rm

boolean that indicates whether to ignore NA values

conf.interval

confidence interval range

tonumeric

whether to convert variables/columns to numeric whenever possible

Value

A data.table

Note

Code adapted from R cookbook (see references)

Author

Hause Lin

Examples

stderror(data = mtcars, measurevar = c("mpg", "disp"), groupvars = c("cyl", "am"))
#> $mpg #> cyl am N mpg sd se ci #> 1: 4 0 3 22.90000 1.4525839 0.8386497 3.608418 #> 2: 4 1 8 28.07500 4.4838599 1.5852839 3.748601 #> 3: 6 0 4 19.12500 1.6317169 0.8158584 2.596426 #> 4: 6 1 3 20.56667 0.7505553 0.4333333 1.864483 #> 5: 8 0 12 15.05000 2.7743959 0.8008991 1.762767 #> 6: 8 1 2 15.40000 0.5656854 0.4000000 5.082482 #> #> $disp #> cyl am N disp sd se ci #> 1: 4 0 3 135.8667 13.969371 8.065220 34.70184 #> 2: 4 1 8 93.6125 20.476777 7.239634 17.11901 #> 3: 6 0 4 204.5500 44.742634 22.371317 71.19552 #> 4: 6 1 3 155.0000 8.660254 5.000000 21.51326 #> 5: 8 0 12 357.6167 71.823494 20.733657 45.63447 #> 6: 8 1 2 326.0000 35.355339 25.000000 317.65512 #>
stderror(data = ChickWeight, measurevar = "weight", groupvars = "Diet")
#> Diet N weight sd se ci #> 1: 1 220 102.6455 56.65655 3.819784 7.528242 #> 2: 2 120 122.6167 71.60749 6.536840 12.943596 #> 3: 3 120 142.9500 86.54176 7.900146 15.643078 #> 4: 4 118 135.2627 68.82871 6.336197 12.548506