Learn R Programming

rmongodb (version 1.8.0)

mongo.cursor.to.data.frame: Convert Mongo Cursor Object to Data.Frame

Description

Converts a mongo cursor object to a data.frame by interating over all cursor objects and combining them.

Usage

mongo.cursor.to.data.frame(cursor, nullToNA = TRUE, ...)

Arguments

cursor
(mongo.cursor) A mongo.cursor object returned from mongo.find().
nullToNA
(boolean) If NULL values will be torned into NA values. Usually this is a good idea, because sporadic NULL values will cause structural problems in the data.frame, whereas NA values will just appear as regular NAs.
...
Additional parameters parsed to the function as.data.frame

Value

An R data.frame object.

Details

Note that mongo.oid columns will be removed. data.frame can not deal with them.

See Also

mongo.find, as.data.frame.

Examples

Run this code
mongo <- mongo.create()
if (mongo.is.connected(mongo)) {
    buf <- mongo.bson.buffer.create()
    mongo.bson.buffer.append(buf, "age", 22L)
    query <- mongo.bson.from.buffer(buf)

    # Find the first 100 records
    #    in collection people of database test where age == 22
    cursor <- mongo.find(mongo, "test.people", query, limit=100L)

   res <- mongo.cursor.to.data.frame(cursor)

}

Run the code above in your browser using DataLab