essentials-package {essentials}R Documentation

Essential Functions not Included in Base R

Description

Functions for converting objects to scalars (vectors of length 1) and a more inclusive definition of data that can be interpreted as numbers (numeric and complex alike).

Details

The four most important functions from this package are as.numbers, is.numbers, as.scalar and aslength1.

as.numbers coerces its argument to type double or complex. is.numbers tests if its argument is interpretable as numbers.

as.scalar coerces its argument to an scalar (an atomic vector of length 1). It strips attributes including names.

aslength1 coerces its argument to a vector of length 1 (not necessarily atomic). It strips attributes from arguments that are not vectors, but preserves names for arguments that are vectors.

Author(s)

Andrew Simmons

Maintainer: Andrew Simmons <akwsimmo@gmail.com>

Examples

as.numbers("4")
as.numbers("4+0i")  # imaginary component is removed
as.numbers("4+1i")

is.numbers(4L)
is.numbers(4)
is.numbers(4+1i)

as.scalar(1:100)
as.scalar(as.list(1:100))  # coerced to NA_character_ since argument isn't atomic

aslength1(1:100)  # identical to as.scalar(1:100)
aslength1(as.list(1:100))  # returns a list of length 1

[Package essentials version 0.1.0 Index]