title: R Mongolite package: aggregrate, unwind, project
body: <p>My MongoDB has a collection with documents, and some of the documents have elements. To get a data frame in R, one needs to unwind the elements of the document "data". The statement (see below) within the aggregate () was written in Robomongo and works well. </p>
  
  <pre><code>con &lt;- mongo(collection = "A",db = "B", url = "mongodb://abc")
  h &lt;- con$aggregate('[{"$match" : {}},
                       {"$project": {
                         "_data":1
                       }
                       },
                       {"$unwind": "$_data"},
                       {"$project": {
                       "Field1": "$_data.Field1",
                       "Field2": "$_data.Field2",
                       "Field3": "$_data.Field3",
                       "Field4": "$_data.Field4",
                       "Field5": "$_data.Field5",
                       "Field6": "$_data.Field6"
                       }
                       },
                       ]')
  </code></pre>
  
  <p>Alas, wenn running it from R using the Mongolit package I get the error:</p>
  
  <pre><code>Error: Invalid JSON object: [{"$match" : {
                      _id:1
                      _data: 1}},
  
                  {"$project": {
                    "_data":1
                  }
                  },
  </code></pre>
  
  <p>Please, can anyone adapt my statement to proper R mongolite-mongodb syntax?
  Thanks a million!</p>