add_index: Add index

Description Usage Arguments Value See Also Examples

View source: R/add_index.R

Description

Add a rowwise mean or sum index of specific variables to the dataset.

Usage

1
add_index(data, name, ..., type = "mean", na.rm = TRUE, cast.numeric = FALSE)

Arguments

data

a tibble

name

Name of the index column to compute.

...

Variables used for the index.

type

Type of index to compute. Either "mean" (default) or "sum".

na.rm

a logical value indicating whether NA values should be stripped before the computation proceeds. Defaults to TRUE.

cast.numeric

a logical value indicating whether all variables selected for index computation should be converted to numeric. Useful if computing indices from factor variables. Defaults to FALSE.

Value

a tibble

See Also

get_reliability() to compute reliability estimates of added index variables.

Examples

1
2
WoJ %>% add_index(ethical_flexibility, ethics_1, ethics_2, ethics_3, ethics_4)
WoJ %>% add_index(ethical_flexibility, ethics_1, ethics_2, ethics_3, ethics_4, type = "sum")

tidycomm documentation built on July 6, 2021, 5:07 p.m.