serializeDataFrame {raven.rdf} | R Documentation |
Serializes the specified data.frame object to a vector of raw bytes.
Description
The R data.frame is serialized as a Raven DataFrame. The concrete column types to use for each individual data.frame column can be specified by the 'types' argument.
Usage
serializeDataFrame(df, types = NULL, compress = FALSE, as.nullable = FALSE)
Arguments
df |
The data.frame object to serialize |
types |
The type names for all column types. Must be a vector of character values. May be NULL |
compress |
A logical indicating whether to compress the content of the returned raw vector |
as.nullable |
A logical indicating whether the data.frame should be serialized as a NullableDataFrame, even if it contains no NA values |
Details
The column types of the R data.frame object are mapped to the corresponding Raven DataFrame column types. The following types exist:
Type name | Description |
byte | int8 |
short | int16 |
int | int32 |
long | int64 |
float | float32 |
double | float64 |
string | UTF-8 encoded unicode string |
char | single printable ASCII character |
boolean | logical value TRUE or FALSE |
binary | arbitrary length byte array |
By default, if the 'types' argument is not explicitly specified, all values are mapped to the corresponding largest possible type in order to avoid possible loss of information. However, users can specify the concrete type for each column in the DataFrame file to be written. This is done by providing a vector of character values denoting the type name of each corresponding data.frame column. The index of each entry corresponds to the index of the column in the underlying data.frame to persist.
If the specified data.frame object contains at least one NA value, then the serialized DataFrame will represent a NullableDataFrame. If the data.frame contains no NA values, then the serialized DataFrame will represent a DefaultDataFrame, unless the 'as.nullable' argument is set to TRUE.
The logical 'compress' argument specifies whether the serialized DataFrame is compressed.
Value
A raw vector representing the serialized date.frame object
See Also
writeDataFrame()
for directly persisting data.frame objects
to the file system
Examples
## Not run:
# get a data.frame
df <- cars
# serialize the data.frame to a raw vector
vec <- serializeDataFrame(df)
# specify the concrete types of all columns
coltypes <- c("float", "double")
# serialize the data.frame to a raw vector with concrete types
serializeDataFrame(df, types = coltypes)
## End(Not run)