| asNumeric | R Documentation |
a number-like object is coerced to type (typeof)
"numeric", keeping dim (and maybe
dimnames) when present.
asNumeric(x)
x |
a “number-like” object, e.g., big integer
( |
an R object of type (typeof) "numeric", a matrix
or array if x had non-NULL dimension dim().
signature(x = "ANY")the default method, which is the
identity for numeric array.
signature(x = "bigq")the method for big rationals.
signature(x = "bigq")the method for big integers.
Note that package Rmpfr provides methods for its own number-like objects.
Martin Maechler
as.numeric coerces to both "numeric" and to a
vector, whereas asNumeric() should keep
dim (and other) attributes.
m <- matrix(1:6, 2,3)
stopifnot(identical(m, asNumeric(m)))# remains matrix
(M <- as.bigz(m) / 5) ##-> "bigq" matrix
asNumeric(M) # numeric matrix
stopifnot(all.equal(asNumeric(M), m/5))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.