writeDataFrame {raven.rdf} | R Documentation |
Writes the specified data.frame to the specified file.
Description
The R data.frame is persisted as a DataFrame (.df) file. The concrete column types to use for each individual data.frame column can be specified by the 'types' argument.
Usage
writeDataFrame(filepath, df, types = NULL, as.nullable = FALSE)
Arguments
filepath |
The path to the file to write |
df |
The data.frame object to write |
types |
The type names for all column types. Must be a vector of character values. May be NULL |
as.nullable |
A logical indicating whether the data.frame should be persisted 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 DataFrame file to be persisted will represent a NullableDataFrame. If the data.frame contains no NA values, then the DataFrame file to be persisted will represent a DefaultDataFrame, unless the 'as.nullable' argument is set to TRUE.
Value
The number of bytes written to the specified file
See Also
serializeDataFrame()
for serializing data.frame objects
to vectors of raw bytes.
readDataFrame()
for reading DataFrame files which have been
previously persisted by this function.
Examples
## Not run:
# get a data.frame
df <- cars
# write the data.frame to a .df file
writeDataFrame("cars.df", df)
# specify the concrete types of all columns
coltypes <- c("float", "double")
# write the data.frame to a .df file with concrete types
writeDataFrame("cars.df", df, types = coltypes)
## End(Not run)