r-hub / blog

The R-hub blog
https://blog.r-hub.io/
11 stars 12 forks source link

JS in R packages #115

Closed maelle closed 4 years ago

maelle commented 4 years ago

JS in R packages

https://cran.r-project.org/web/packages/V8/vignettes/v8_intro.html

https://cran.r-project.org/web/packages/js/vignettes/intro.html

https://www.mail-archive.com/r-package-devel@r-project.org/msg05417.html

https://colinfay.me/node-r-package/ (needs Node and npm installed locally)

JS in knitr/ R Markdown

JS literate programming

https://rmarkdown.rstudio.com/authoring_knitr_engines.html%23sql#JavaScript

https://github.com/yihui/knitr/blob/6907b428572c130982f6b3d6c91a164a15b94a30/R/engine.R#L483

https://github.com/ColinFay/bubble#knitr

https://pkg.js4shiny.com/reference/html_document_js.html

View time for knitr and one option of js4shiny, compile time for bubble and one option of js4shiny.

Different problem

https://community.rstudio.com/t/proper-way-to-do-dependency-ingestion-of-js-for-rmarkdown/64807 (that's a thing you'd distribute in a package)

Shiny

https://connect.thinkr.fr/js4shinyfieldnotes/read-more.html#shiny-js

https://shiny.rstudio.com/articles/packaging-javascript.html

CDN https://github.com/feddelegrand7/bubblyr/blob/master/R/bubbly.R

Shiny apps as packages https://golemverse.org/

htmlwidgets

https://cran.r-project.org/web/packages/htmlwidgets/index.html

JS for R users, how to learn

JS literate programming

but adds a level of complexity

Learning materials

https://connect.thinkr.fr/js4shinyfieldnotes/

https://github.com/rstudio-conf-2020/js-for-shiny

Playground

https://pkg.js4shiny.com/reference/repl.html cf comment below

Others

https://hackernoon.com/r-and-javascript-execution-libraries-integration-40a30726f295

maelle commented 4 years ago

Using a CDN in https://github.com/feddelegrand7/scrollrevealR

https://github.com/gadenbuie/countdown htmltools https://github.com/gadenbuie/countdown/blob/a544fa48e2248996002e059ca07ad620d2aec3a8/R/countdown.R#L245

gadenbuie commented 4 years ago

Hi @maelle! This post looks like yet another blockbuster! 😄

If you're going to talk about the js knitr engine that ships with knitr, you might be interested in an R Markdown output format I created for the js4shiny package called html_document_js(). It overrides the default js knitr engine so that, in addition to the JavaScript code is running in the browser, output and console.log() statements are written into code chunks just like R code, but interactively and in the browser! (I can work up an example for you if you want.)

For R users who are learning JavaScript, the js4shiny package also includes a Shiny app slash RStudio addin with an interactive REPL for running JavaScript or prototyping web pages — it's a lot like a local version of codepen.io. You can fire it up by calling repl() or repl_js().

Finally, instead of countdown, I'd offer xaringanExtra as a better example of a few approaches to web dependency management in R packages:

maelle commented 4 years ago

Thank you!! I'm glad you find the topic interesting, I might ping you once I have a draft (with no pressure!). Thanks a ton for the resources.

maelle commented 4 years ago

https://colinfay.me/hello-hordes/

maelle commented 4 years ago

https://github.com/rstudio-conf-2020/js-for-shiny (no blog post on RStudio Education yet?)

@gadenbuie that is a very impressive workshop website btw!!

maelle commented 4 years ago

Three topics

maelle commented 4 years ago

And add something about JS in man pages cf #56

maelle commented 4 years ago

For vignettes, link to vignettes articles, for pkgdown remind that there can be incompatibilities when you e.g. add a leaflet map

maelle commented 4 years ago

Also the topic of learning, depends on what language you're learning (JS as an R user or vice versa) and what for. Add links to a few resources.