Closed deann88 closed 5 years ago
This is unfortunately by design, because the JSON format does not natively support NA values. So we need to convert them either to null or to a string. You can control this with the na
argument:
m <- mongolite::mongo('testtypes')
mydata <- list(a = NA_real_, b = NA_integer_, c = NA_character_)
m$insert(mydata, na = 'null', auto_unbox = TRUE)
m$insert(mydata, na = 'string', auto_unbox = TRUE)
m$export()
m$drop()
I have observed this behaviour which seems pretty strange to me.
If we have a NA value in R which belongs to a numeric format, I would expect it not to appear in mongo at all or be null, however, in mongo it changes type and becomes a string with value "NA".
Versions. jsonlite - 1.5 mongolite - 2.0