as_chr: Convert to character

Description Usage Arguments Details See Also Examples

View source: R/as_chr.R

Description

Convert to character

Usage

1
2
3
4
5
6
7
as_chr(x, ..., na)

## Default S3 method:
as_chr(x, ..., na)

## S3 method for class 'logical'
as_chr(x, true = "TRUE", false = "FALSE", na)

Arguments

x

logical vector

na

string; value to set for NA (missing values)

true

string for TRUE value

false

string for FALSE value

Details

as_chr converts x to character. It is smarter versions of base::as.character().

The default method wraps base::as.character().

The method for logical values allows for mapping TRUE, FALSE and NA values to values to Using non-default values fortrueorfalse' results in non-invertible transformation. (true="T", false="F" is also invertible )

This also allows for setting TRUE or FALSE values to NA

See Also

Examples

1
2
3
4
  v <- c(TRUE, FALSE, NA )
  as_chr(v) 
  as_chr(v, "T", "F" )
  as_chr(v, true="T", false=NA )

decisionpatterns/coercion documentation built on Nov. 4, 2019, 10:23 a.m.