Learn R Programming

essentials (version 0.1.0)

essentials-package: essentials

Description

essentials

Arguments

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.

Examples

Run this code
# NOT RUN {
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
# }

Run the code above in your browser using DataLab