ropensci / unconf15

rOpenSci's San Francisco hackathon/unconf 2015
http://unconf.ropensci.org
35 stars 7 forks source link

JavaScript in R #2

Open jeroen opened 9 years ago

jeroen commented 9 years ago

The V8 package (a fully standalone JavaScript engine in R) is pretty stable by now. If you have some JavaScript scripts or libraries that you would like to expose in R, I can help writing bindings. I am also interested to learn if you use JavaScript in R in some other way (shiny or htmlwidgets or so); perhaps we could support server side validation/preprocessing.

Simple examples: viz.js or sql.js or cheerio. Also try the js package, which implements bindings to uglify-js and jshint:

devtools::install_github("jeroenooms/js")

Basic examples:

library(js)
code <- "function test(x, y){ x = x || 1; y = y || 1; return x*y;}"
cat(uglify_optimize(code))
cat(uglify_reformat(code, beautify = TRUE, indent_level = 2))
jshint(uglify_optimize(code))
noamross commented 9 years ago

+1 on this. I'm interested in the relationship between this and #3 (API wrappers), and possibly Rcpp, in that I'd like to discuss what design patterns should be used for javascript-wrapping packages. Related questions:

Relatedly, I'm interested in something that uses PhantomJS or something like it to scrape pages as rendered in browsers, a la quickscrape, which I tried to wrap but haven't made much progress on.

srvanderplas commented 9 years ago

I'm interested in something that uses PhantomJS or something like it to scrape pages as rendered in browsers, a la quickscrape, which I tried to wrap but haven't made much progress on.

I missed this initially, but I would be very interested in this as well