簡體   English   中英

桑基圖 R 不顯示

[英]Sankey plot R not displaying

鏈接數據:

  from    to  freq
  <int> <int> <int>
1     0     0     1
2     0     1    33
3     0     2    22
4     1     0    22
5     1     1     1
6     1     2    32

nodes = data.frame( names = unique(Data$names))%>%add_row(names = "other") 


sankeyNetwork( Links = as.data.frame( linkdata), Nodes = nodes, Source = "from",
                   Target = "to", Value = "freq" , NodeID = "names",
                   fontSize = 12, nodeWidth = 30)

該圖未顯示。 我根據 StackOverflow 上的答案在節點中添加了一個新行,即使這不起作用。

數據只包含一些我想命名陽光圖中標簽的名稱。

  names
1 a
2 b
3 c
4 d
5 e
6 f
7 other

也許還有其他事情你沒有在這里告訴我們? 這對我有用...

library(networkD3)

linkdata <- read.table(stringsAsFactors = F, header = T, text = 
'from  to  freq
0     0     1
0     1    33
0     2    22
1     0    22
1     1     1
1     2    32
')

Data <- read.table(stringsAsFactors = F, header = T, text = '
names
a
b
c
d
e
f
other
')

sankeyNetwork(Links = linkdata, Nodes = Data, Source = "from", Target = "to", 
          Value = "freq" , NodeID = "names", fontSize = 12, nodeWidth = 30)

在此處輸入圖片說明

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM