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 dataframe (tibble)

Note

Code adapted from R cookbook (see references)

Examples

stderror(data = mtcars, measurevar = c("mpg", "disp"), groupvars = c("cyl", "am"))
#> $mpg #> # A tibble: 6 x 7 #> cyl am N mpg sd se ci #> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> #> 1 4 0 3 22.9 1.45 0.839 3.61 #> 2 4 1 8 28.1 4.48 1.59 3.75 #> 3 6 0 4 19.1 1.63 0.816 2.60 #> 4 6 1 3 20.6 0.751 0.433 1.86 #> 5 8 0 12 15.0 2.77 0.801 1.76 #> 6 8 1 2 15.4 0.566 0.4 5.08 #> #> $disp #> # A tibble: 6 x 7 #> cyl am N disp sd se ci #> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> #> 1 4 0 3 136. 14.0 8.07 34.7 #> 2 4 1 8 93.6 20.5 7.24 17.1 #> 3 6 0 4 205. 44.7 22.4 71.2 #> 4 6 1 3 155 8.66 5. 21.5 #> 5 8 0 12 358. 71.8 20.7 45.6 #> 6 8 1 2 326 35.4 25 318. #>
stderror(data = ChickWeight, measurevar = "weight", groupvars = "Diet")
#> # A tibble: 4 x 6 #> Diet N weight sd se ci #> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> #> 1 1 220 103. 56.7 3.82 7.53 #> 2 2 120 123. 71.6 6.54 12.9 #> 3 3 120 143. 86.5 7.90 15.6 #> 4 4 118 135. 68.8 6.34 12.5