Learn R Programming

capl (version 1.39)

validate_scale: Check whether a response to a given questionnaire item or scale is valid.

Description

This function checks whether a vector for a given questionnaire item or scale is valid.

Usage

validate_scale(x, lower_bound = NA, upper_bound = NA)

Arguments

x

A numeric (integer) vector representing the response to a questionnaire item (valid values are between the values set by the lower_bound and upper_bound argumetns).

lower_bound

A numeric (integer) vector representing the value below which x is invalid.

upper_bound

A numeric (integer) vector representing the value above which x is invalid.

Value

Returns a numeric (integer) vector (if valid) or NA (if not valid).

Examples

Run this code
# NOT RUN {
validate_scale(
  x = c(0:10, NA, "7"),
  lower_bound = 1,
  upper_bound = 7
)

# [1] NA  1  2  3  4  5  6  7 NA NA NA NA  7

# }

Run the code above in your browser using DataLab