3

I'm trying to create an HTML Rmarkdown that runs many plotly graphs... The issues in the HTML file is too big and can't open it.

I found out that I can use "partial_bundle" function to reduce the size of my file. On my home computer it works great.

I created the following file:

```{r pressure, echo=FALSE, error=TRUE}
dta  = data.frame(x= rnorm(1000), y = rnorm(1000))

plot_ly(dta, x=~x,y=~y) 
```

Its size is ~5Mb and when I add the funtion "partial_bundle":

```{r pressure, echo=FALSE, error=TRUE}
dta  = data.frame(x= rnorm(1000), y = rnorm(1000))

plot_ly(dta, x=~x,y=~y)  %>%
  partial_bundle() 

```

The size reduces to ~2.5Mb which is great.

The issues is in my work environment, the function doesn't work because it seems like it needs to access a server that it's blocked in my work:

enter image description here

It there a way to use it offline? There is a description here of the function but I dont get how to use it offline on Rmarkdown..

Edit: My end goal is to know how use the js script on barchart plotlys... I need help implementing the js files in my rmarkdown...

shafee
  • 15,566
  • 3
  • 19
  • 47
AnonX
  • 167
  • 8
  • I didn't know that an `rmd` output in `html` requires server access (unless it's a Shiny app). For me it opens just fine in the browser. – Ed_Gravy Aug 02 '22 at 19:34
  • It opens fine even without internet connexion? I tried using in my home computer without access to internet and I get the same error... – AnonX Aug 02 '22 at 19:36
  • Yes you are right, it doesn't work without an internet connection, have you tried knitting it without the `partial_bundle` function? – Ed_Gravy Aug 02 '22 at 19:44
  • Look at this [question](https://stackoverflow.com/questions/32428819/knitr-rmarkdown-reducing-html-file-size) – Ed_Gravy Aug 02 '22 at 19:49
  • 3
    @Ed_Gravy without the "partial_bundle" it produces a bigger file ~5Mb and with the "partial_bundle" the file is ~2.5Mb... – AnonX Aug 02 '22 at 19:58
  • Maybe [this](https://stackoverflow.com/questions/46406570/is-it-reasonable-to-create-a-presentation-in-r-markdown-no-internet-connection) will help in running the `html` without an internet connection. – Ed_Gravy Aug 02 '22 at 20:40
  • What is your R session info on each environment, and plotly versions. Can you install new packages in each environment? – Daniel_j_iii Aug 02 '22 at 23:48
  • I have R version 4.1.2 and plotly_4.10.0 – AnonX Aug 03 '22 at 02:11
  • Do you need a standalone file? – Stéphane Laurent Aug 03 '22 at 06:18
  • @StéphaneLaurent I need to run the "partial_bundle" offline... – AnonX Aug 03 '22 at 07:11
  • You are not able to use `bundle_plotly()` offline. You could render `bundle_partial` with the `local=TRUE` argument at home, and save the file offline and then send it to your work computer to view offline. Plotly and Rmarkdown use a lot of Javascript dependiencies that take up disk space – Daniel_j_iii Aug 03 '22 at 11:56
  • If you knit at home, the HTML file is independent. (You won't need the internet to open the HTML.) Alternatively, you could download the partial bundles you need from the Plotly webpage, then use a JS chunk to swap out the JS for Plotly. [Info on that is here](https://github.com/plotly/plotly.js/tree/master/dist). If you need help with how you would implement this after you download a bundle, edit your question with your YAML and basic plot information (bar, scatter, pie, etc.) Or ask another question with this info. – Kat Aug 03 '22 at 19:48
  • @Daniel_j_iii thanks for this. I guess I can't use then because the data are in my work station and I can't take them out of our work system... – AnonX Aug 03 '22 at 20:22
  • Yaml? Sorry it must sounds dumb but I don't know what it is. And yes I need help on how to implement those js files in my rmarkdown... Im plotting bar charts btw.... – AnonX Aug 03 '22 at 20:24

0 Answers0