block by timelyportfolio d93785f4d8be972e14e8

d93785f4d8be972e14e8

I very much like the idea of selectn.js, so I wanted to see if there is anything like it in R. Here is some code to at least start the conversation in my head.

library(purrr)
library(jsonlite)
library(V8)

ctx <- v8()

# get selectn to use in our V8 context
ctx$source("https://npmcdn.com/selectn/selectn.min.js")

# send array or list-of-lists to V8 to use as demo
# see what Titanic list-of-list looks like
array_tree(Titanic) %>% str()
ctx$assign('titanic',array_tree(Titanic))

# try out selectn
ctx$get('selectn("0.0.0.1",titanic)')
array_tree(Titanic)[[c(1,1,1,2)]]
map(array_tree(Titanic),c(1,1,2))[1]

# error handling
#  selectn returns undefined
ctx$get('selectn("0.0.3",titanic)')
ctx$get('selectn("0.0.3",titanic)===undefined')
array_tree(Titanic)[[c(1,1,4)]]