Description Usage Arguments Details Value See Also Examples
Convert a data object to simple form.
1 | as.simple(x)
|
x |
object to be converted. |
Simple data objects are the only values allowed in a keyset. Plain
atomic vectors are simple, subject to certain restrictions on the values
described below, as are certain object vectors including
factor
, Date
, and POSIXct
. A dataset is simple
whenever all its columns are simple.
The as.simple
function converts its argument to a simple
data object or fails with an error if no conversion is possible.
The default implementation of as.simple
splits a matrix-like
object into a dataset of columns and calls as.simple
on each
column. Plain atomic vectors get converted as follows:
double
: negative zero (-0
) gets
converted to zero; all non-NA
not-a-numbjer NaN
values get converted to the canonical NaN
.
character
: all entries not in "bytes"
encoding get converted to ASCII ("unknown"
) or
"UTF-8"
encoding.
complex
: the real and imaginary parts get
converted to simple double; all NA
values get
converted to the canonical complex NA
.
Objects with class Date
, factor
, and POSIXct
have their underlying storage converted to simple. Objects
with class POSIXlt
get converted to simple POSIXct
Calls to as.simple
with a list object x
or an object
without an implementation of as.simple
will raise an error.
The object x
converted to a simple data object.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | # objects that are already simple stay unchanged
as.simple(NULL)
as.simple(1:10)
as.simple(factor(letters))
# double: replace -0 by 0 (also, replace non-canonical NaN with NaN)
x <- c(1.3, 0, -0)
y <- as.simple(x)
1 / x
1 / y
# POSIXlt get converted to simple POSIXct
time <- as.POSIXlt(Sys.time())
class(time)
class(as.simple(time))
# matrix-like objects get converted to datasets of columns
as.simple(matrix(1:20, 4, 5))
as.simple(iris)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.