dot-scalar1: Coerce to numeric scalar safely

.scalar1R Documentation

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_)

Arguments

x

Object to be coerced to numeric.

default

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

Value

A numeric scalar or default if extraction fails.


bivarhr documentation built on July 7, 2026, 1:06 a.m.