numeric. There is a big data analog;
see
.
numeric(length=0) is.numeric(x) as.numeric(x)
numeric returns a simple object of mode
"numeric" and the length specified.
The storage mode is
"double". If length is greater than 0, the values
in this vector are
0.
is.numeric returns
TRUE if
x has mode
"numeric" or
"bdNumeric". Otherwise, it returns
FALSE.
Its behavior is unaffected by any attributes of
x; for example,
x could
be a numeric array (in contrast to the behavior of
is.vector).
as.numeric returns a vector like
x, but with storage mode
"double",
if
x is a simple object of mode
"numeric".
Otherwise,
as.numeric returns a numeric object of the same length as
x
and with data resulting from coercing the elements of
x to mode
"numeric".
bdNumeric to a
numeric, you must call
bd.coerce.
There is a difference between coercing to a simple object of mode
"numeric"
and setting the mode attribute:
mode(myobject) <- "numeric"
This changes the mode of
myobject but leaves all other attributes unchanged
(so a matrix stays a matrix, e.g.). The value of
as.numeric(myobject)
has no attributes.
When
x is of mode
"numeric", the data of
x may
be stored as integers or single or double precision
floating point numbers, and
storage.mode(x) will be
"integer",
"single", or
"double", respectively.
Normally, all numeric constants that appear in expressions
are read with mode
numeric and storage mode
double.
This distinction is only relevant when using the
interface to languages like C or Fortran.
The class of simple objects have no attributes.
In most S-PLUS expressions it is not
necessary to explicitly ensure that data are of a particular mode.
In S-PLUS 5.0 and later, zero-length operands in arithmetic operations force
zero-length results. That is,
numeric(0) + anything yields
numeric(0).
Earlier versions of S-PLUS returned a vector of
NAs as long as the longer
operand.
z <- numeric(length(zz)) # double object same length as zz
Results are currently computed to single-precision accuracy only.
.Fortran("mydsub",as.double(xm))