我沿着这个线创建了一个情节:
http://www.buildingwidgets.com/blog/2015/7/2/week-26-sunburstr
# devtools::install_github("timelyportfolio/sunburstR")
library(sunburstR)
# read in sample visit-sequences.csv data provided in source
# https://gist.github.com/kerryrodden/7090426#file-visit-sequences-csv
sequence_data <- read.csv(
paste0(
"https://gist.githubusercontent.com/kerryrodden/7090426/"
,"raw/ad00fcf422541f19b70af5a8a4c5e1460254e6be/visit-sequences.csv"
)
,header=F
,stringsAsFactors = FALSE
)
Run Code Online (Sandbox Code Playgroud)
在 Rstudio 中,我可以在查看器中单击:“导出 > 另存为网页...”
然后将绘图保存为交互式 html 文档。我想将此作为代码的一部分。如何使用 R 代码将绘图保存到 html?PDF/jpg 等有很多示例,但没有 html。
将森伯斯特存储在一个变量中并用于htmltools::save_html保存它。
plot <- sunburst(sequence_data)
htmltools::save_html(plot, file = "C:/Users/User/Desktop/sunburst.html")
Run Code Online (Sandbox Code Playgroud)