Description Usage Arguments Value Note See Also Examples
Convert a mongo.bson object to an R list object.
1 | mongo.bson.to.list(b, simplify = TRUE)
|
b |
(mongo.bson) The mongo.bson object to convert. |
simplify |
logical (default: TRUE); should the bson arrays be simplified to a vectors if possible? If types of values in bson array are heterogeneous or non-primitive, array will be converted into list. |
an R object of the type list
Now arrays in bson document are 1) converted into unnamed lists 2) If simplify == TRUE, function tries to turn arrays of primitive types into R vectors. Please see examples below;
mongo.bson.from.list
, mongo.bson.to.Robject
,
mongo.bson.
1 2 3 4 5 6 7 8 9 10 11 12 | # arrays will be converted into unnamed lists without any symplifying:
l <- list(storageArray = list('value_1', 'value_2'))
# Here we construct bson of form {'storageArray':['value_1''value_2']}
b <- mongo.bson.from.list(l)
# simplify
print(mongo.bson.to.list(b, simplify = TRUE))
# not simplify
print(mongo.bson.to.list(b, simplify = FALSE))
# heterogeneous types of array values
print(mongo.bson.to.list(mongo.bson.from.list(list(x = list('a', 1))), simplify = TRUE))
# identical to call with simplify = F
print(mongo.bson.to.list(mongo.bson.from.list(list(x = list('a', 1))), simplify = FALSE))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.