| numbers | R Documentation |
Creates or coerces objects of type “numeric” or “complex”.
is.numbers is a more general test of an object being interpretable as
numbers.
numbers(length = 0)
as.numbers(x, ...)
is.numbers(x)
## Default S3 method:
as.numbers(x, strict = TRUE, ...)
length |
A non-negative integer specifying the desired length. Double values will be coerced to integer: supplying an argument of length other than one is an error. |
x |
object to be coerced or tested. |
strict |
|
... |
further arguments passed to or from other methods. |
numbers is identical to numeric and
double (and real). It creates a double-precision
vector of the specified length with each element equal to 0.
as.numbers attempts to coerce its argument to be of double or complex
type: like as.vector it strips attributes including names.
is.numbers is a more general test of an object being considered
numbers, meaning the base type of the class is double or
integer or complex and values can reasonably be regarded
as numbers (e.g., arithmetic on them makes sense, and comparison should be
done via the base type).
for numbers see double.
as.numbers returns either a double or complex vector.
is.numbers returns TRUE if its argument is of
mode "numeric" or "complex" and not a factor, and FALSE
otherwise.
x <- 1:5
names(x) <- c("a", "b", "c", "d", "e")
as.numbers(x) # vector converted from integer to double, names removed
x <- x + 0i # x is now a complex vector
as.numbers(x) # vector of type double since all numbers were purely real
## vector of type complex, despite being purely real
as.numbers(x, strict = FALSE)
x <- x + 1i
## vector remains of type complex since numbers are not purely real
as.numbers(x)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.