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)
答案 0 :(得分:1)
您可以使用htmltools::save_html
或htmlwidgets::saveWidget
。
c = collapsibleTree(org, c("Manager", "Employee"), collapsed = FALSE)
htmltools::save_html(c, file='file.html')
htmlwidgets::saveWidget(c, file="file2.html")
请注意,后者会抱怨没有标题。