Learn R Programming

whapi (version 0.0.2)

whapi_to_num: Safely coerce to numeric

Description

Utility to coerce a value into numeric (double), returning NA_real_ if input is NULL or NA.

Usage

whapi_to_num(x)

Value

A numeric scalar (double) or NA_real_.

Arguments

x

Any R object (usually scalar).

Examples

Run this code
whapi_to_num("123")
whapi_to_num(NULL)   # NA_real_

Run the code above in your browser using DataLab