ramnathv / htmlwidgets

HTML Widgets for R
http://htmlwidgets.org
Other
783 stars 207 forks source link

saveWidget is not working when saving in a different folder from the current working directory #319

Open lucazav opened 5 years ago

lucazav commented 5 years ago

All is explained into the code:

nodes <- data.frame(id = 1:3)
edges <- data.frame(from = c(1,2), to = c(1,3))
net <- visNetwork(nodes, edges, main = "visNetwork minimal example")

# in this way the 'net_1_files' folder will be generated
setwd("c:/")
htmlwidgets::saveWidget(net, file="c:/temp/net_1.html", selfcontained = T)

# in this way the 'net_1_files' folder will NOT be generated, as expected
setwd("c:/temp")
htmlwidgets::saveWidget(net, file="c:/temp/net_1.html", selfcontained = T)
bfgray3 commented 5 years ago

I ran into a similar issue when trying to save a file in a subdirectory of the current working directory, with saveWidget throwing the following error:

Error in normalizePath(basepath, "/", TRUE) : 
  path[1]="foo": No such file or directory

Using normalizePath myself on the path I'm passing to the function solved the problem, but it would be convenient if saveWidget could handle this path expansion by itself.

versipellis commented 5 years ago

Been happening since February #299

Ruismart commented 2 months ago

that's right, me too, have to save in current working dir, then move to anywhere u like, or 'selfcontained = T' wouldn't work. but it's not a big deal~