to_sd_categories: to_sd_categories

View source: R/utils.R

to_sd_categoriesR Documentation

to_sd_categories

Description

Convert a numeric into a factor divided into three categories according to standard deviation (Below 1 SD, within 1 SD, greater than 1 SD). Useful for plotting interactions with continuous variables.

Usage

to_sd_categories(x, na.rm = FALSE)

Arguments

x

Vector of numeric values

na.rm

If true, remove NAs when calculating mean and SD. If NAs are present and na.rm is false, output will be all NAs

Value

Vector of 3 level factor by standard deviation.

Examples

myVec <- c(1,6,3,6,8,4,19,5,4,1,7,17,20,9,5,5,11,4,3,4,11,4,2,2)
myCategoricalVec <- to_sd_categories(myVec)


amehtaSF/rsurveyutils documentation built on Aug. 27, 2022, 11:59 a.m.