Reputation: 1143
I am struggling to create a Sankey diagram using the package "riverplot". I did not manage to create a minimal toy example, so I have to include the riverplot object created by makeRiver()
here. makeRiver
did not throw any errors, so I thought it would work, but it does not. I hope that anyone of you has an idea.
This is the riverplot object I am trying to plot:
$edges
ID N1 N2 Value
102 102 2 10 3
106 106 6 10 2
111 111 2 11 7
115 115 6 11 2
119 119 1 12 1
120 120 2 12 72
121 121 3 12 4
125 125 7 12 7
127 127 9 12 4
129 129 2 13 14
134 134 7 13 2
136 136 9 13 1
145 145 9 14 1
147 147 2 15 4
152 152 7 15 1
154 154 9 15 1
156 156 2 16 1
165 165 2 17 69
166 166 3 17 3
167 167 4 17 1
168 168 5 17 1
169 169 6 17 2
170 170 7 17 7
171 171 8 17 1
172 172 9 17 8
$nodes
ID labels x
1 1 Albanisch 1
2 2 Arabisch 1
3 3 Arabisch;Englisch 1
4 4 Arabisch;Türkisch 1
5 5 Englisch;Kurdisch;Arabisch 1
6 6 Kurdisch 1
7 7 Kurdisch;Arabisch 1
8 8 Syrisch;Arabisch 1
9 9 keine 1
10 10 Arabisch 2
11 11 Arabisch;Englisch 2
12 12 Englisch 2
13 13 Englisch;Französisch 2
14 14 Englisch;Französisch;Arabisch 2
15 15 Französisch 2
16 16 Französisch;Englisch 2
17 17 keine 2
$styles
list()
attr(,"class")
[1] "list" "riverplot"
Calling riverplot(river)
("river" being the name of the variable I saved the object in), I get the following output (sorry that the error message is in German, it says "Index(ing) out of bounds"):
[1] "calculating positions"
[1] 21.9
ID labels x
1 1 Albanisch 1
2 2 Arabisch 1
3 3 Arabisch;Englisch 1
4 4 Arabisch;Türkisch 1
5 5 Englisch;Kurdisch;Arabisch 1
6 6 Kurdisch 1
7 7 Kurdisch;Arabisch 1
8 8 Syrisch;Arabisch 1
9 9 keine 1
10 10 Arabisch 2
11 11 Arabisch;Englisch 2
12 12 Englisch 2
13 13 Englisch;Französisch 2
14 14 Englisch;Französisch;Arabisch 2
15 15 Französisch 2
16 16 Französisch;Englisch 2
17 17 keine 2
[1] "done"
[1] "drawing edges"
Fehler in styles[[id]] : Indizierung außerhalb der Grenzen
I THINK I traced the problem to the function riverplot:::getattr
, but I am not sure about that. Any help?
Upvotes: 0
Views: 121
Reputation: 1143
In case anyone is interested in the solution to the problem I described above: I used numeric IDs for nodes (1, 2, 3, ...) and edges (101, 102, ...).
makeRiver()
checks if IDs are duplicated among nodes and edges and throws an error if that happens. However, it does NOT check if the IDs are purely numeric, which is apparently the source of the error.
I now added an "E" at the beginning of the edge IDs (E1, E2, ...) and an "N" at the beginning of node IDs (N1, N2, ...). It works now!
Upvotes: 0