convert_str_to_logical: Converts a character vector to logicals

View source: R/helpers.R

convert_str_to_logicalR Documentation

Converts a character vector to logicals

Description

Takes a character vector and converts it to logicals, optionally using a vector of patterns to match against for truthy and falsy values.

Usage

convert_str_to_logical(
  x,
  truthy = c("T", "TRUE", "Y", "YES"),
  falsy = c("F", "FALSE", "N", "NO")
)

Arguments

x

A character vector.

truthy

A vector of case-insensitive truthy values to turn into TRUE.

falsy

A vector of case-insensitive falsy values to turn into FALSE.

Value

A logical vector.

Examples

convert_str_to_logical(c('YES', 'Y', 'No', 'N', 'YES', 'yes', 'no', 'Yes', 'NO', 'Y', 'y'))


upstartr documentation built on May 29, 2024, 9:08 a.m.