Transfer mongodb ISODate to R

I am currently transferring my data to R with the RMongo package. I want to specify a date range to pull in my R session at this point with

library('RMongo') #Connect to the database mongo <- mongoDbConnect('db') #results from dates. result <- dbGetQuery(mongo, 'statsdb', '<query>', 0,200000) Where my <query> is { "createdAt" : { "$gte" : ISODate("2012-12-01T00:00:00Z"), "$lt" : ISODate("2013-01-01T00:00:00Z") } } 

I get errors:

Error in .jcall( rmongo.object@javaMongo , "S", "dbGetQuery", collection, : com.mongodb.util.JSONParseException:

Is there any specific way that I need to transfer mondodb ISODates to R with RMongo package?

+4
source share
1 answer

I just spent a lot of time struggling with it myself. If you're still looking for an answer, the key seems to be in extended JSON from MongoDB; cm

http://docs.mongodb.org/manual/reference/mongodb-extended-json/

For your request you can write

 query = "{ createdAt : { $gte : { $date: '2012-12-01T00:00:00Z' }, $lt : { $date: '2013-01-01T00:00:00Z' } } }" 
+5
source

Source: https://habr.com/ru/post/1496575/


All Articles