Closed gonzalezivan90 closed 6 years ago
Is there are reason you're not inserting using plain JSON? This inserts a value of null
into Mongo:
insertObject <- jsonlite::toJSON(list("one" = 1, "RNA" = NA), auto_unbox = TRUE)
mdb <- mongo(db = ...)
mdb$insert(insertObject)
Result in Mongo is:
{ "_id" : ObjectId("5b2c1cd2b92f1f12606fa728"), "one" : 1, "RNA" : null }
Thanks, Serenthia. I got this error:
library(mongolite)
library(jsonlite)
> testMDB$insert(insertObjectList)
Error: is.data.frame(data) is not TRUE
other attached packages:
[1] jsonlite_1.0 mongolite_0.8.1
I have to say that my objects are data,frame-like but I can reshape them Thanks a lot
You need to upgrade mongolite to the latest version! Then you can use named lists or JSON strings as your input.
Absolutely yes! Thanks a lot. Greetings from Colombia
Hi, I tried write a value that appears as null into mongo. I need that the field become created into the record/document in mongo. Any suggestions?
mdb <- mongo(db = ... ) mdb$insert(data.frame(one = 1, RNA = NA)) # don't write RNA field mdb$insert(data.frame(one = 1, RNULL = NULL)) # Can't create data frame mdb$insert(data.frame(na = NA, one = 1, listNull = list(NULL), asNull = as.null(1), asNullDef = as.null.default(1)) # Can't create data frame