simple: Simple Data Objects

Description Usage Arguments Details Value See Also Examples

Description

Convert a data object to simple form.

Usage

1

Arguments

x

object to be converted.

Details

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:

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.

Value

The object x converted to a simple data object.

See Also

keyset.

Examples

 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)

patperry/r-frame documentation built on May 6, 2019, 8:34 p.m.