Error loading R package

Questions on GAMS MIRO
Post Reply
Anka
User
User
Posts: 4
Joined: 6 months ago

Error loading R package

Post by Anka » 6 months ago

Hello MIRO-experts,

I just started to play around with GAMS MIRO and I currently try to build my own custom widget. Sadly, I'm not able to make the R package "sf" usable. As described in the documentation, I added the R package to the json file:

"result": {
"outType": "mymap",
"packages": ["leaflet", "sf"]
}

and I reference the function with the package name and double colon within my R file:

polygonsSF = sf::st_read(myfilename, stringsAsFactors=FALSE)

However, I receive the following error message when trying to start MIRO:
Error message: Error in loadNamespace(name): es gibt kein Paket namens 'sf'

Interestingly, the R package "leaflet" does not make any problems, although I found the sf-package in my .miro-folder, and the leaflet-package not.

Am I doing something wrong or may this be a bug?
Thanks in advance for any help!

Update 29.01.21: I found the problem myself: The loaded R package may only be used inside the two specified functions (mynameOutput and renderMyname) and not in the whole R script.

Robin
User
User
Posts: 5
Joined: 3 years ago

Re: Error loading R package

Post by Robin » 6 months ago

Hi Anka,

good to hear that you found a solution. You bring up a good point here. Currently, custom R packages can only be used within these two functions. This was done intentionally, even though it can sometimes lead to limitations. We will think about it again, but I can't promise that anything will change here. Thank you anyway for the hint!

FYI:
- While trying to reproduce your problem, we noticed another issue, that custom R packages are reloaded on every startup. This will be fixed with MIRO 1.3 (to be released in a few days).
- On MacOS, using libraries that include compiled code may lead to issues due to some security features in the latest macOS releases. Also, running your app on MIRO Server requires some tweaking before it works. If you want to make your app work cross-platform and also on MIRO Server, we can provide you with more details (MIRO Server is not yet released, but will be in the next few months).

Robin

Post Reply