首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >sankey plot R不显示降价

sankey plot R不显示降价
EN

Stack Overflow用户
提问于 2021-04-26 14:51:37
回答 1查看 104关注 0票数 0

我正在处理一个R标记文档,但是被一个"sankey chart“元素卡住了。Sankey元素在其代码中工作得很好,但是当我编织markdown时,该元素不会显示在markdown中(或者只是空白)。

迁移流程

代码语言:javascript
复制
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

当我运行代码时,图显示得很好,但是当我编织它时,它不显示,只是留下enter image description here -page空白。

任何帮助都是非常感谢的。谢谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-04-26 17:40:29

我让它起作用了。这是头条新闻-tabset,这就是问题所在。我对它们进行了编辑并修复了它

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67262037

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档