single_value: Ensure that a vector has only a single value throughout.

View source: R/data_cleaners.R

single_valueR Documentation

Ensure that a vector has only a single value throughout.

Description

Missing values are replaced with the single value, and if all values are missing, the first value in missing is used throughout.

Usage

single_value(x, missing = NA, warn_if_all_missing = FALSE, info = NULL)

Arguments

x

The vector which should have a single value

missing

The vector of values to consider missing in x

warn_if_all_missing

Generate a warning if all values are missing?

info

If more than one value is found, append this to the warning or error to assist with determining the location of the issue.

Value

x as the scalar single value found throughout (or an error if more than one value is found).

Examples

single_value(c(NA, 1))

billdenney/bsd.report documentation built on Jan. 16, 2024, 12:54 a.m.