1

I'm on a Linux environment, and I'd like to make standalone HTML widgets in R using Leaflet and DT, and generating the HTML with htmlwidgets plugin. The problem is that when I try to open these generated HTML files, the browser is blank, and some sort of JSON parsing error occurs according to the console.

It only happens in Linux. I've already tried it on Windows with Rstudio, and it worked just fine.

I also found out that on Windows, the javascript widget is base64 encoded inside the HTML file, unlike on Linux.

I don't think it's a problem with htmlwidgets, since there are other widget libraries that I use (rPivotTable, plotly, etc.), and they work just fine on Linux with htmlwidgets.

R sessionInfo() output:

R version 3.3.1 (2016-06-21) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 14.04.4 LTS

The R packages and versions:

  • plotly_4.5.6
  • ggplot2_2.2.0
  • rpivotTable_0.1.5.10
  • htmlwidgets_0.8
  • DT_0.1
  • leaflet_1.0.1

Any idea what causes this? Have anyone ever experienced something similar? I've read questions with similar symptoms, but none of the answers solved the problem for me.

Atka
  • 11
  • 1

1 Answers1

0

Couple of items here: first look at your html output code in the browser for error and second, try updating d3r package. I ran into similar issue where we have security that blocked the packages going out and fetching the javascript packages. Since, d3r was updated to make internal lookup the default option which solved our problem.

Akbar
  • 130
  • 8
  • 1
    The d3r package update didn't work, we didn't even have it in the first place. When I look inside the code of the generated HTML files, the right one has it's javascripts base64 encoded, while the wrong one has it's scripts URL encoded. When I open the wrong one, the developer console of the browser says `Uncaught SyntaxError: Unexpected token \ in JSON at position 582(…)`. – Atka Dec 02 '16 at 15:23
  • 1
    Did you try to look up the json error? here is a quick link: http://stackoverflow.com/questions/14432165/uncaught-syntaxerror-unexpected-token-with-json-parse – Akbar Dec 02 '16 at 18:46