Open JWusagi opened 3 years ago
I'm not that surprised that doesn't work; the dependency files are created in the temp directory of the callr child R process, and when the child process finishes executing, the temp files are deleted.
Usually everything from leaflet()
on down doesn't take very long. Do you know what part of your code is taking a long time to run? (If not, running under profvis would help)
I'm not that surprised that doesn't work; the dependency files are created in the temp directory of the callr child R process, and when the child process finishes executing, the temp files are deleted.
Usually everything from
leaflet()
on down doesn't take very long. Do you know what part of your code is taking a long time to run? (If not, running under profvis would help)
Hi Joe
I can only say thanks so much for the reminder.. Indeed, you are right that there are some lines of codes slow down the whole process, which I can run them in the global environment! Now it's perfectly solved.
I was just too rush in writing all the codes and therefore didn't do performance optimisation well.
Thanks again, Jie
I noticed a similar error when trying to save and later reload leaflet maps that use addProviderTiles()
. In this case the motivation was to include a leaflet map as a 'dataset' in an R package/shiny app without having to create the map within the shiny app itself (which is slower & requires other dependencies, as well as leaflet, in this particular case). Are there any suggested work arounds for this?
Here is a reproducible example run in RStudio:
library(leaflet)
library(magrittr)
# Make map with addTiles()
l1 <-
leaflet() %>%
addTiles()
# Make map with addProviderTiles()
l2 <-
leaflet() %>%
addProviderTiles(provider = providers$Stamen.TonerLite)
# Save maps
saveRDS(l1, "l1.rds")
saveRDS(l2, "l2.rds")
# Restart session & reload maps
rstudioapi::restartSession()
readRDS("l1.rds") # success
readRDS("l2.rds") # failure
# > Error in copyDependencyToDir(dep, libdir, FALSE) :
# > Can't copy dependency files that don't exist: ...
Another scenario where this comes up is if you try to generate, then load a map (using addProviderTiles()) in a targets pipeline.
Hi there
Not sure if it's fair to log this issue here as it relates to two packages -
leaflet
andcallr
. I have a Shiny App that allows users play with coloured interactive map (by leaflet). Every time user changes settings, the map takes around 1 minute to load. Therefore I'm looking to load the map in background so that users can do other works in the App in the meantime. I usedcallr::r_bg()
for background loading:Then I got the following error:
However, the error only exists when I include the
addProviderTiles()
commend, and everything goes OK if I only load the polygons without the background map with rivers, roads, city names, etc. Therefore, I'm considering whether there is a dependency/connection to an online centralised system that I need to bring to thecallr::r_bg()
command.Sorry for bothering - but I'm wondering if anyone get any idea on possible solutions? If this is not the right place for this questions, please shout and I'll log it somewhere else.
Many thanks, Jie