convert: Strict type conversion

Description Usage Arguments Details Value Examples

View source: R/data_functions.R

Description

Function to convert data from one class to that of another data object so that they are comparable.

Usage

1
convert(from, to)

Arguments

from

Data object to be converted.

to

Data object with class to be converted to

Details

Follows R's upwards coercion logic, and is not downwards compatible, i.e, a numeric can be converted to a string, but a string, even "1", will not be converted to numeric.

Value

A data object with the same class as 'to' parameter, if possible.

Examples

1
2
3
4
convert(1, "2")
[1] "1"
convert(T, "I'm a test string")
[1] "TRUE"

andrewjameshaynes/helpeR documentation built on May 28, 2019, 2:44 p.m.