age <- c(5, 8)
height <- c(35, 47)
d <- data.frame(age=age, height=height)
buf <- mongo.bson.buffer.create()
mongo.bson.buffer.append.object(buf, "table", d)
b <- mongo.bson.from.buffer(buf)
# this produces a BSON object of the form:
# { "table" : { "R_OBJ" : true,
# "value" : {
# "age" : [ 5, 8 ],
# "height" : [35, 47 ]
# },
# "attr" : {
# "row.names" : [ -2147483648, -2 ],
# "class" : "data.frame"
# }
# }
# }
# row.names is stored in the compact form used for integer row names.
Run the code above in your browser using DataLab