如何将可折叠树生成的可折叠树图保存到 R 中的 html 文件中



collapsibleTree是一个很棒的打包,可以在R中生成可折叠的树形图。有谁知道我们如何将生成的树形图保存为 html 文件?

org <- data.frame(
Manager = c(
NA, "Ana", "Ana", "Bill", "Bill", "Bill", "Claudette", "Claudette", "Danny",
"Fred", "Fred", "Grace", "Larry", "Larry", "Nicholas", "Nicholas"
),
Employee = c(
"Ana", "Bill", "Larry", "Claudette", "Danny", "Erika", "Fred", "Grace",
"Henri", "Ida", "Joaquin", "Kate", "Mindy", "Nicholas", "Odette", "Peter"
),
Title = c(
"President", "VP Operations", "VP Finance", "Director", "Director", "Scientist",
"Manager", "Manager", "Jr Scientist", "Operator", "Operator", "Associate",
"Analyst", "Director", "Accountant", "Accountant"
)
)
library(collapsibleTree)
collapsibleTree(org, c("Manager", "Employee"), collapsed = FALSE)

您可以使用htmltools::save_htmlhtmlwidgets::saveWidget

c = collapsibleTree(org, c("Manager", "Employee"), collapsed = FALSE)
htmltools::save_html(c, file='file.html')
htmlwidgets::saveWidget(c, file="file2.html")

请注意,后者会抱怨没有标题。

相关内容

  • 没有找到相关文章

最新更新