Learn R Programming

roperators (version 1.3.14)

chr: Cleaner conversion functions

Description

Cleaner conversion functions

convert x to arbitrary class

Usage

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

Examples

Run this code
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

Run the code above in your browser using DataLab