RMI-PACTA / pacta.multi.loanbook.plot

Tools to Plot Climate Metrics for Multiple Loanbooks
https://rmi-pacta.github.io/pacta.multi.loanbook.plot/
Other
0 stars 0 forks source link

expand `~/` paths before passing to `webshot::webshot()` #37

Closed cjyetman closed 3 weeks ago

cjyetman commented 3 weeks ago

phantomjs does not appear to understand ~/ paths and does not expand it to the user's home directory (it makes a sub directory ./~ 😱) as one might expect (at least not on my system: macOS 15 on arm64 M3 / R 4.4.1), so it would be advantageous to expand ~/ paths before passing them on to webshot, e.g. webshot::webshot(temp_html, path.expand("~/Desktop/sankey.png"), vwidth = 1000, vheight = 900)

test <- data.frame(
  group_id = c("A", "A", "B", "B"),
  middle_node = c("auto", "power", "auto", "power"),
  is_aligned = c("Aligned", "Aligned", "Not aligned", "Not aligned"),
  loan_size_outstanding = c(10, 12, 14, 8)
)

pacta.multi.loanbook.plot::plot_sankey(
  data = test,
  group_var = "group_id",
  save_png_to = "./",
  png_name = "sankey.png",
  nodes_order_from_data = TRUE
)

list.files("./")
#> [1] "jolly-bass_reprex.R"        "jolly-bass_reprex.spin.R"  
#> [3] "jolly-bass_reprex.spin.Rmd" "sankey.png"

pacta.multi.loanbook.plot::plot_sankey(
  data = test,
  group_var = "group_id",
  save_png_to = "~/",
  png_name = "sankey.png",
  nodes_order_from_data = TRUE
)

list.files("~/")
#>  [1] "Applications" "data"         "Desktop"      "Documents"    "Downloads"   
#>  [6] "github"       "Library"      "Movies"       "Music"        "Pictures"    
#> [11] "Public"
list.files("./~/")
#> [1] "sankey.png"