Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

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

Closed
cjyetman opened this issue Aug 18, 2024 · 0 comments · Fixed by #38
Closed

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

cjyetman opened this issue Aug 18, 2024 · 0 comments · Fixed by #38

Comments

@cjyetman
Copy link
Member

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"
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant