Summarises a numerical variable by one or more grouping variables. The result can be supplied directly to plotting code.

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

Arguments

data

A data frame.

numerical

Name of the numerical variable to summarise.

factors

Character vector naming the grouping variables.

size

Multiplier applied to the standard deviation or standard error.

type

Either "sd" for standard deviation or "std" for standard error.

Value

A data frame containing the grouping variables, group mean, and the requested spread measure.

Examples

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