Savewidget from htmlwidget to R, cannot save html file in another folder

I have a flyer that I want to save in an html file in a specific folder. I am using windows 7.

I tried the following:

library(htmlwidgets) saveWidget(map_leaflet, file="ressources/test.html") library(htmlwidgets) saveWidget(map_leaflet, file="ressources\\test.html") library(htmlwidgets) path_name <- file.path("ressources", "test.html", fsep="\\") saveWidget(map_leaflet, file=path_name) library(htmlwidgets) path_name <- paste("ressources", "test.html", sep="/") saveWidget(map_leaflet, file=path_name) 

As an error message, depending on the Rstudio session, I have

1) Error in setwd (dir): cannot change working directory

2) Unable to find the path

When I save only this:

 library(htmlwidgets) saveWidget(map_leaflet, file="test.html") 

It works great.

Thank you in advance for your help.

+7
html r save htmlwidget
source share
1 answer

I agree.

here is a workaround:

 f<-"ressources\\test.html" saveWidget(map_leaflet,file.path(normalizePath(dirname(f)),basename(f))) 

The problems look like this: saveWidget does not work with relative path names, and normalizePath does not work for paths to existing files.

I would call it an error in saveWidget.

edit:

I am contributing to what, in my opinion, is an even more effective solution to the existing open problem.

+6
source share

All Articles