Learn R Programming

bivarhr (version 0.1.5)

.scalar1: Coerce to numeric scalar safely

Description

Helper to coerce an object to numeric and return a single scalar if possible. If coercion fails, the result is non-finite, or the length is not exactly 1, a default value is returned.

Usage

.scalar1(x, default = NA_real_)

Value

A numeric scalar or default if extraction fails.

Arguments

x

Object to be coerced to numeric.

default

Numeric scalar returned when a valid scalar cannot be extracted (default is NA_real_).