简体   繁体   English

sankey plot R 不显示 markdown

[英]sankey plot R not displaying markdown

I'm working on an R markdown document but am stuck with a "sankey chart" element.我正在研究 R markdown 文档,但我坚持使用“sankey chart”元素。 The Sankey element works fine in its code, but when I knit markdown the element doesn't show up in the markdown (or is just blank[?]). Sankey 元素在其代码中运行良好,但是当我编织 markdown 时,该元素不会出现在 markdown 中(或者只是空白[?])。

Migration flow 迁移流程
 library(networkD3) # creating the df uni_reenrolled <- c("CBS","KU", "DTU","RUC", "AU", "ITU", "AAU", "SDU", "DTU", "KU", "SDU", "CBS", "AAU", "RUC", "ITU", "AU", "KU", "ITU", "CBS", "DTU", "SDU", "KU", "CBS", "DTU", "RUC", "SDU", "AU", "AAU", "ITU", "KU", "SDU", "CBS", "RUC", "AU", "AAU", "DTU", "ITU", "SDU", "KU", "AU", "AAU", "RUC", "DTU", "CBS", "ITU", "AAU", "AU", "KU", "SDU", "DTU", "CBS", "RUC", "ITU", "AU", "AAU", "SDU", "KU", "CBS", "RUC", "DTU", "ITU") uni_dropout<- c("CBS","CBS", "CBS", "CBS", "CBS", "CBS", "CBS", "CBS", "DTU", "DTU", "DTU", "DTU", "DTU", "DTU", "DTU", "DTU", "ITU", "ITU", "ITU", "ITU", "ITU", "KU", "KU", "KU", "KU", "KU", "KU", "KU", "KU", "RUC", "RUC", "RUC", "RUC", "RUC", "RUC", "RUC", "RUC", "SDU", "SDU", "SDU", "SDU", "SDU", "SDU", "SDU", "SDU", "AAU", "AAU", "AAU", "AAU", "AAU", "AAU", "AAU", "AAU", "AU", "AU", "AU", "AU", "AU", "AU", "AU","AU") dropout <- c(274, 272, 48, 40, 29, 27, 25, 22, 604, 275, 66, 53, 41, 29, 27, 23, 27, 21, 16, 8, 6, 1093, 199, 175, 141, 129, 99, 78, 55, 147, 53, 44, 27, 23, 18, 14, 12, 1254, 124, 99, 56, 45, 44, 28, 5, 939, 140, 85, 69, 56, 27, 24, 8, 1810, 176, 166, 94, 34, 33, 21, 5) sankey_uni_data <- data.frame(dropout, uni_reenrolled, uni_dropout)%>% mutate(uni_reenrolled = paste0(" ",uni_reenrolled )) # creating the sankey-chart node_names <- (c(as.character(unique(sankey_uni_data$uni_dropout)), unique(as.character(sankey_uni_data$uni_reenrolled)))) nodes <- data.frame(name = node_names) links <- data.frame(source = match(sankey_uni_data$uni_dropout, node_names) - 1, target = match(sankey_uni_data$uni_reenrolled, node_names) - 1, value = sankey_uni_data$dropout) sn <-sankeyNetwork(Links = links, Nodes = nodes, Source = "source", Target = "target", Value = "value", NodeID = "name", units = "dropouts", fontSize = 25, nodeWidth = 30, fontFamily = "sans-serif", iterations = 0) sn

When i'm running the code the diagram comes out just fine enter image description here , but when i'm knit'ing it, it doesn't show, and just leaves the markdown-page blank.当我运行代码时,图表出来就好了,在这里输入图像描述,但是当我编织它时,它没有显示,只是将降价页面留空。

Any help is appreciated.任何帮助表示赞赏。 Thanks!谢谢!

I got it to work.我让它工作。 It was headlines -tabset, that was the problem.这是头条新闻-tabset,这就是问题所在。 I edited them and that fixed it我编辑了它们并修复了它

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM