Black Lives Matter. Please consider donating to Black Girls Code today.

Saving plot_ly object as .rds file and displaying in separate computer


I am building a shiny app from an .Rmd file which mainly displays some animations and plots. To make the page load faster I’ve made all the plot_ly objects locally, store them and then simply load and display them on the shiny server side.

In local script:

p = economics %>% plot_ly(x = ~pop, y = ~pce, type = "scatter", mode = "markers")
saveRDS(p, "plot.rds")

In shiny server:

p = readRDS("plot.rds")

And then hope that gets displayed (but it does not). Instead, I get the following in my log:

Warning: Error in value[[3L]]: Couldn't normalize path in `addResourcePath`, with arguments: `prefix` = 'jquery-1.11.3'; `directoryPath` = '/Library/Frameworks/R.framework/Versions/3.6/Resources/library/crosstalk/lib/jquery'

I have seen in other internet posts that this is a problem to do with the plot_ly object dependencies and there are some tedious workarounds using htmlwidgets which I have failed to use.

Has anybody managed to make this work? Any help/discussion is appreciated.