Create a dataframe with which a ggplot2 bar plot with error bars (+/- 1 standard deviation) can be created.

create_error_bar_df(data, numerical, factors, size = 1, type = "sd")

Arguments

data

The original data set.

numerical

The numerical variable which will be visualised in the bar plot.

factors

One or more factor variables which will be used for grouping. Use c("var1", "var2") for multiple grouping variables.

size

Choose whether you want more/less than 1 standard deviation/standard error. Defaults to 1.

type

Choose between "sd" (standard deviation) and "std" (standard error). Defaults to "sd".

Value

A dataframe object.

References

Wickham, H. (2016) ggplot2: Elegant Graphics for Data Analysis. Springer-Verlag New York.

Author

D. Schmitz

Examples

data("data_s")

create_error_bar_df(data = data_s, numerical = "sDur", factors = "pauseBin", size = 1, type = "sd")
#>   pauseBin      sDur         sd
#> 1 no_pause 0.1095498 0.03404740
#> 2    pause 0.1654329 0.06289761