cleaner_conversions: Cleaner conversion functions

Description Usage Arguments Note Author(s) Examples

Description

Cleaner conversion functions

convert x to arbitrary class

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
chr(x, ...)

int(x, ...)

dbl(x, ...)

num(x, ...)

bool(x, ...)

as.class(x, class)

Arguments

x

object to be converted

...

other args for as. conversion

class

chatracter name of the class to convert x to

Note

These are shorthand aliases for common conversions There is nothing magical here, but it can make your code more readable

Author(s)

Steven Nydick, steven.nydick@kornferry.com

Ben Wiseman, benjamin.wiseman@kornferry.com

Ben Wiseman, benjamin.wiseman@kornferry.com

Ben Wiseman, benjamin.wiseman@kornferry.com

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
chr(42)   # "42" = as.character
int(42.1) # 42L  = as.integer
dbl("42L") # 42.0 = as.double
num("42") # 42   = as.numeric
bool(42)  # TRUE = as.logical


foo <- 255
as.class(foo, "roman")
# [1] CCLV

roperators documentation built on Feb. 10, 2022, 1:07 a.m.