After opening a connection between a RethinkDB database and R using the rethinker package in R, how might I alter the following ReQL code (which runs in Data Explorer of RethinkDB web admin UI) so that the query may be executed directly from R?
r.db('DB').table('table_name')
.merge(function(x){
return {x_count: x("name").count().default(0)}
}).merge(function(y) {
return {
y_name: r.db("DB").table("table_name2").getAll(y_name("name2"), {index: "index_name"})
.filter(function (z) {
return z("z_name").contains(z("z_id"))
}).nth(0).default({y_name: null})("yName")
}}).eqJoin('name_t', r.db('DB').table('table_t')).default({name_t1: null})
For reference, the equivalent syntax for running the following ReQL code from an open connection to a rethinkDB (cn) in R is as follows:
To query the table 'table_name'
from the RethinkDB 'DB_name'
using ReQL:
r.db('DB_name').table('table_name')
using R:
r()$db("DB_name")$table("table_name")$run(cn)