Learn R Programming

rmongodb (version 1.8.0)

mongo.bson.from.df: Convert a data.frame to a mongo.bson object

Description

Convert a data.frame to a mongo.bson object.

Usage

mongo.bson.from.df(df)

Arguments

df
(data.frame) The data.frame to convert.

This must be a data.frame, not a vector of atomic types; otherwise, an error is thrown; use as.data.frame() as necessary.

Value

(mongo.bson) A mongo.bson object serialized from data.frame.

Details

This function permits the simple and convenient creation of a mongo.bson object. This bypasses the creation of a mongo.bson.buffer, appending fields one by one, and then turning the buffer into a mongo.bson object with mongo.bson.from.buffer().

See Also

mongo.bson.to.list, mongo.bson, mongo.bson.destroy.

Examples

Run this code
df <- data.frame(name=c("John", "Peter"), age=c(32,18))
b <- mongo.bson.from.df(df)

Run the code above in your browser using DataLab