I'd like to create different sizes for my nodes based on the value associated with that node.
I'm getting these weird number emoticons instead of what I'd expect for the legend labels.
I'm using RStudio Server on a linux machine and I've not had this error with ggplot
This is my visualization
This is my code
library(GGraph)
library(network)
netval1 <-
network(netmat1_matrix, matrix.type = "edgelist")
netval1_tidy <-
as_tbl_graph(netval1)
ggraph(netval1_tidy) +
geom_edge_link() +
geom_node_point(aes(size = (c))) +
theme_graph()
This is my data
structure(c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 12, 12,
12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13,
13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15,
15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16,
17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18,
18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19,
19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
22, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 24, 24,
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26,
26, 26, 27, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29,
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 30, 30, 30, 30, 30,
31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 33, 33, 34,
34, 34, 34, 34, 34, 34, 34, 34, 34, 35, 35, 35, 35, 35, 36, 36,
36, 36, 36, 37, 37, 37, 38, 38, 38, 39, 39, 39, 39, 39, 39, 39,
39, 39, 39, 40, 40, 40, 40, 41, 41, 41, 42, 42, 42, 42, 42, 42,
42, 42, 43, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44,
44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 45, 45, 45,
45, 45, 45, 45, 45, 46, 46, 47, 47, 47, 47, 47, 47, 47, 47, 48,
49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 50, 50, 50, 50,
50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 51, 51, 51, 51, 51, 52,
52, 52, 52, 52, 52, 52, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53,
53, 53, 54, 54, 54, 54, 54, 54, 54, 54, 54, 55, 55, 55, 55, 55,
55, 55, 55, 55, 56, 56, 56, 56, 56, 56, 56, 56, 57, 57, 57, 57,
57, 57, 57, 58, 58, 58, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59,
59, 60, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 62, 62, 62,
62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 63, 63, 64, 64, 64,
64, 64, 64, 65, 66, 66, 66, 66, 67, 67, 67, 67, 67, 67, 67, 67,
67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 68,
68, 68, 68, 68, 68, 68, 68, 69, 69, 69, 70, 70, 70, 71, 71, 71,
71, 71, 72, 72, 72, 72, 72, 72, 72, 72, 73, 73, 73, 73, 73, 73,
74, 74, 74, 74, 74, 74, 74, 75, 75, 75, 75, 75, 75, 75, 75, 75,
75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 76, 76, 76, 76, 76,
76, 76, 76, 76, 76, 77, 77, 78, 78, 78, 79, 79, 79, 79, 79, 79,
80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 81, 81, 81,
81, 81, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 83,
83, 83, 83, 83, 84, 85, 86, 86, 86, 86, 86, 86, 86, 86, 87, 87,
87, 88, 88, 88, 89, 89, 89, 89, 89, 89, 89, 90, 90, 90, 90, 90,
90, 90, 90, 90, 90, 90, 91, 91, 91, 91, 91, 91, 92, 92, 92, 92,
93, 93, 93, 93, 93, 93, 93, 93, 94, 94, 94, 95, 95, 95, 95, 95,
96, 96, 96, 97, 97, 97, 97, 97, 97, 98, 98, 98, 98, 98, 99, 99,
99, 99, 99, 100, 100, 100, 100, 101, 101, 101, 101, 102, 102,
103, 103, 104, 104, 105, 105, 105, 106, 106, 106, 106, 106, 107,
107, 108, 108, 108, 108, 108, 108, 108, 108, 109, 109, 109, 109,
109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 110, 110,
110, 110, 110, 111, 111, 112, 112, 113, 113, 113, 113, 113, 114,
114, 114, 114, 114, 114, 114, 114, 114, 114, 115, 115, 115, 115,
115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 116,
116, 117, 117, 117, 117, 118, 119, 119, 119, 119, 120, 120, 120,
121, 121, 121, 121, 121, 121, 121, 122, 122, 122, 122, 123, 123,
124, 124, 124, 125, 125, 125, 125, 125, 125, 125, 126, 126, 126,
126, 127, 127, 127, 127, 127, 127, 127, 127, 128, 128, 128, 128,
129, 129, 129, 129, 130, 130, 130, 131, 131, 132, 132, 132, 132,
132, 132, 133, 133, 133, 133, 133, 133, 133, 133, 134, 134, 134,
134, 135, 135, 136, 136, 137, 138, 139, 139, 139, 140, 140, 140,
140, 140, 141, 141, 141, 141, 141, 141, 141, 142, 142, 142, 142,
142, 143, 143, 144, 144, 144, 144, 144, 144, 144, 145, 145, 145,
146, 146, 146, 147, 147, 148, 148, 149, 149, 149, 150, 150, 150,
150, 150, 151, 151, 151, 151, 151, 151, 151, 151, 151, 152, 152,
152, 152, 153, 153, 153, 153, 154, 154, 155, 155, 155, 155, 155,
155, 156, 156, 156, 156, 157, 157, 158, 158, 158, 159, 159, 159,
159, 159, 160, 161, 161, 162, 162, 163, 163, 163, 163, 163, 164,
164, 165, 165, 165, 165, 165, 165, 166, 166, 166, 167, 167, 167,
167, 168, 168, 168, 168, 169, 170, 171, 171, 172, 172, 172, 172,
173, 173, 173, 174, 174, 175, 175, 175, 175, 175, 176, 177, 177,
177, 177, 178, 179, 180, 181, 181, 181, 182, 183, 183, 183, 183,
183, 184, 184, 185, 185, 186, 187, 187, 187, 187, 188, 188, 188,
189, 189, 190, 190, 191, 191, 191, 192, 192, 193, 193, 194, 194,
195, 195, 196, 197, 197, 197, 198, 198, 199, 200, 201, 202, 203,
203, 204, 205, 205, 206, 206, 207, 208, 209, 1, 27, 28, 58, 108,
120, 161, 178, 181, 208, 2, 6, 18, 97, 104, 140, 3, 10, 17, 23,
28, 42, 45, 92, 100, 102, 111, 113, 148, 167, 175, 178, 180,
183, 194, 4, 31, 34, 62, 63, 72, 79, 98, 155, 162, 166, 187,
3, 5, 27, 37, 47, 102, 110, 131, 154, 164, 2, 6, 52, 68, 97,
104, 139, 140, 150, 157, 165, 5, 7, 116, 131, 180, 8, 11, 22,
35, 51, 55, 60, 64, 65, 71, 88, 95, 107, 118, 124, 138, 154,
177, 9, 21, 25, 44, 45, 49, 54, 59, 90, 93, 94, 96, 129, 186,
198, 3, 10, 13, 17, 32, 42, 47, 61, 77, 92, 93, 96, 100, 113,
122, 131, 148, 151, 156, 158, 175, 183, 195, 11, 60, 107, 12,
13, 15, 18, 20, 25, 29, 74, 76, 109, 121, 141, 144, 173, 206,
10, 13, 14, 15, 44, 59, 62, 67, 75, 76, 97, 109, 122, 128, 141,
144, 173, 184, 186, 189, 198, 13, 14, 40, 44, 54, 67, 68, 75,
76, 77, 83, 109, 119, 123, 137, 141, 142, 144, 151, 155, 168,
204, 206, 15, 19, 26, 28, 40, 82, 83, 98, 99, 108, 120, 126,
140, 181, 8, 16, 22, 45, 64, 65, 95, 138, 177, 3, 17, 33, 36,
48, 100, 113, 6, 12, 18, 20, 26, 29, 30, 72, 75, 79, 98, 105,
109, 119, 123, 129, 133, 140, 141, 152, 192, 204, 15, 19, 40,
41, 99, 134, 139, 2, 19, 20, 54, 57, 72, 80, 90, 129, 133, 134,
137, 139, 188, 192, 203, 4, 9, 12, 13, 16, 21, 23, 24, 45, 49,
50, 54, 94, 114, 198, 22, 35, 51, 55, 65, 71, 78, 85, 88, 107,
118, 124, 138, 154, 23, 44, 49, 50, 76, 97, 109, 112, 130, 141,
144, 151, 195, 13, 14, 24, 29, 44, 62, 67, 75, 76, 83, 109, 114,
128, 137, 139, 141, 144, 149, 153, 189, 193, 206, 13, 14, 25,
109, 128, 173, 184, 193, 2, 12, 18, 26, 72, 75, 27, 3, 28, 103,
108, 120, 208, 14, 24, 29, 67, 75, 83, 109, 114, 115, 121, 125,
137, 141, 142, 153, 196, 202, 204, 9, 16, 30, 101, 139, 31, 114,
149, 165, 166, 173, 191, 193, 198, 17, 32, 36, 37, 33, 43, 34,
44, 54, 62, 72, 98, 162, 164, 166, 189, 1, 35, 50, 91, 170, 17,
36, 41, 48, 131, 32, 37, 158, 38, 90, 192, 20, 21, 26, 39, 70,
87, 90, 94, 155, 171, 15, 19, 40, 148, 41, 116, 163, 3, 7, 10,
42, 47, 102, 131, 148, 43, 4, 9, 13, 16, 21, 23, 24, 25, 34,
44, 49, 50, 54, 59, 67, 82, 84, 91, 97, 106, 109, 134, 144, 186,
189, NA, 21, 45, 62, 110, 151, 162, 206, 209, 46, 164, 36, 37,
42, 47, 93, 100, 113, 132, 48, 2, 6, 12, 15, 18, 19, 20, 26,
29, 38, 44, 49, 53, 56, 74, 75, 79, 86, 94, 105, 121, 129, 130,
133, 150, 157, 172, 190, 6, 34, 35, 44, 50, 52, 54, 59, 97, 123,
133, 156, 157, 189, 11, 51, 55, 88, 118, 6, 18, 50, 52, 125,
157, 159, 13, 15, 18, 20, 53, 57, 89, 123, 130, 168, 188, 204,
9, 16, 30, 34, 54, 90, 97, 129, 198, 41, 51, 55, 71, 116, 124,
156, 163, 193, 56, 106, 121, 159, 184, 187, 191, 192, 13, 40,
53, 57, 75, 123, 204, 28, 58, 120, 13, 44, 59, 68, 76, 77, 96,
114, 141, 144, 195, 60, 10, 30, 49, 61, 77, 93, 100, 145, 154,
172, 209, 22, 24, 30, 45, 54, 62, 98, 110, 149, 151, 162, 166,
189, 206, 63, 204, 8, 22, 64, 95, 138, 161, 65, 47, 66, 116,
145, 13, 14, 24, 29, 44, 49, 55, 62, 67, 75, 76, 97, 109, 114,
125, 137, 139, 141, 144, 163, 189, 193, 206, 14, 68, 77, 81,
113, 136, 179, 195, 69, 113, 158, 39, 70, 171, 71, 78, 88, 107,
124, 26, 34, 62, 72, 79, 86, 98, 139, 73, 77, 81, 106, 181, 197,
49, 59, 74, 89, 172, 188, 201, 12, 14, 18, 24, 26, 29, 53, 67,
75, 83, 114, 115, 121, 123, 125, 141, 142, 153, 196, 204, 25,
44, 49, 76, 114, 141, 144, 173, 193, 198, 59, 77, 8, 22, 78,
26, 29, 63, 79, 98, 153, 12, 13, 18, 25, 74, 80, 82, 105, 130,
173, 184, 188, 199, 14, 73, 81, 172, 179, 44, 50, 62, 76, 82,
109, 121, 139, 141, 144, 156, 189, 203, 29, 67, 83, 115, 137,
84, 85, 4, 31, 40, 63, 79, 86, 155, 187, 39, 87, 94, 71, 88,
118, 18, 57, 74, 89, 97, 141, 188, 54, 90, 94, 98, 105, 123,
129, 133, 188, 189, 200, 9, 16, 21, 54, 91, 134, 92, 148, 158,
176, 10, 46, 93, 97, 113, 158, 189, 195, 87, 94, 192, 8, 64,
95, 124, 138, 49, 96, 197, 76, 89, 97, 141, 144, 150, 18, 34,
79, 98, 162, 15, 40, 90, 91, 99, 10, 69, 100, 113, 30, 90, 101,
129, 3, 102, 28, 103, 15, 104, 105, 168, 188, 13, 56, 106, 184,
192, 11, 107, 27, 28, 58, 108, 130, 161, 181, 208, 12, 24, 25,
29, 44, 49, 59, 67, 76, 82, 109, 114, 144, 198, 206, 45, 62,
110, 151, 209, 111, 167, 112, 182, 47, 48, 93, 113, 197, 24,
29, 76, 114, 137, 149, 173, 191, 193, 198, 14, 24, 29, 67, 75,
83, 114, 115, 121, 125, 137, 142, 153, 196, 202, 204, 41, 116,
64, 84, 117, 170, 118, 102, 119, 144, 189, 28, 63, 120, 13, 56,
82, 99, 106, 121, 123, 10, 122, 160, 175, 74, 123, 7, 8, 124,
56, 115, 125, 153, 193, 196, 204, 40, 104, 126, 174, 9, 12, 13,
16, 21, 23, 24, 49, 47, 55, 93, 128, 30, 90, 129, 139, 112, 130,
133, 36, 131, 17, 36, 47, 48, 113, 132, 52, 90, 98, 123, 133,
136, 157, 179, 20, 54, 134, 190, 120, 135, 87, 136, 137, 138,
18, 19, 139, 18, 30, 94, 140, 190, 6, 56, 94, 123, 129, 139,
141, 14, 29, 75, 142, 153, 143, 189, 14, 16, 68, 83, 137, 144,
203, 41, 66, 145, 51, 146, 177, 147, 176, 148, 175, 149, 189,
193, 97, 130, 139, 141, 150, 10, 62, 76, 77, 122, 151, 175, 182,
206, 18, 101, 139, 152, 114, 115, 125, 153, 49, 154, 4, 20, 90,
155, 168, 184, 10, 76, 93, 156, 30, 157, 14, 96, 158, 20, 72,
98, 159, 190, 160, 120, 161, 62, 162, 51, 55, 116, 128, 163,
27, 46, 44, 76, 97, 141, 144, 165, 31, 76, 166, 3, 10, 111, 167,
105, 168, 184, 200, 169, 170, 70, 171, 77, 81, 93, 172, 109,
173, 198, 99, 174, 111, 148, 175, 183, 194, 176, 107, 135, 146,
177, 178, 179, 180, 28, 108, 181, 182, 10, 175, 180, 183, 194,
130, 184, 18, 185, 186, 2, 4, 159, 187, 68, 188, 201, 143, 189,
174, 190, 56, 166, 191, 80, 192, 76, 193, 3, 194, 68, 77, 196,
17, 77, 197, 21, 198, 199, 200, 201, 202, 136, 203, 204, 110,
139, 151, 206, 207, 28, 209, 36, 2, 4, 5, 6, 2, 2, 1, 1, 2, 246,
3, 1, 2, 4, 2, 47, 7, 3, 1, 1, 3, 1, 1, 4, 5, 9, 2, 3, 8, 1,
1, 10, 4, 1, 88, 2, 1, 1, 2, 1, 3, 1, 2, 1, 1, 1, 1, 18, 1, 1,
5, 5, 1, 1, 1, 4, 15, 65, 6, 2, 1, 2, 1, 2, 1, 2, 2, 1, 51, 2,
1, 9, 37, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2,
59, 13, 1, 2, 3, 1, 8, 4, 2, 2, 1, 1, 2, 1, 3, 5, 31, 1, 2, 4,
5, 4, 1, 4, 1, 5, 1, 1, 1, 5, 5, 2, 1, 1, 3, 10, 3, 1, 85, 4,
1, 88, 2, 2, 1, 3, 1, 1, 1, 1, 2, 1, 1, 1, 4, 1, 1, 77, 1, 1,
1, 1, 1, 1, 1, 3, 2, 3, 1, 4, 2, 2, 2, 3, 1, 1, 1, 2, 70, 2,
1, 1, 1, 1, 1, 1, 2, 2, 2, 1, 1, 17, 1, 1, 6, 1, 1, 1, 1, 1,
36, 2, 1, 1, 5, 1, 1, 1, 4, 1, 1,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 2), .Dim = c(1227L, 3L), .Dimnames = list(
NULL, c("a", "b", "c")))
You aesthetic c seems to be an issue here. Consider sample data below.
num_nodes <- 10
my_sociomatrix <- matrix(round(runif(num_nodes*num_nodes)), # edge values
nrow = num_nodes, #nrow must be same as ncol
ncol = num_nodes)
diag(my_sociomatrix) <- 0
net <- as.network(x = my_sociomatrix, # the network object
directed = TRUE, # specify whether the network is directed
loops = FALSE, # do we allow self ties (should not allow them)
matrix.type = "adjacency" # the type of input
)
network.vertex.names(net) <- LETTERS[1:10]
# Create the variable
gender <- c(rep("Female",num_nodes/2),rep("Male",num_nodes/2))
# Add it to the network object
set.vertex.attribute(net, # the name of the network object
"Gender", # the name we want to reference the variable by in that object
gender # the value we are giving that variable
)
age <- round(rnorm(num_nodes,20,3))
set.vertex.attribute(net,"Age",age)
summary.network(net, # the network we want to look at
print.adj = FALSE # if TRUE then this will print out the whole adjacency matrix.
)
Using your graph program
ggraph(net) +
geom_edge_link() +
geom_node_point(aes(size=age/5)) +
theme_graph()
Related
I'm trying to extract slope values from a number of linear regression models. I plotting acetone emission against water content on different days.
I have these graphs and models
I have tried to extract the slope values using this code:
Library(broom)
Library(tidyverse)
lm_table <- df %>%
nest_by(days) %>%
summarise(mdl = list(lm(water_content ~ acetone, data)), .groups = "drop") %>%
mutate(adjrsquared = map_dbl(mdl, ~summary(.)$adj.r.squared ),
mdl = map(mdl, broom::tidy)) %>%
unnest(mdl)%>%
filter(term=="acetone")
and also this code:
lm_table2 <- df %>%
nest_by(days) %>%
mutate(model = list(lm(water_content ~ acetone, data)),
coefficients2 = list(tidy(model)))
coefficients2 = lm_table2 %>%
unnest(coefficients2)
Both codes however give different slope values than what I get from the graphs. Any ideas as to why that is?
Here's the data
df <- structure(list(i.x45.03 = c(22, 17, 11, 1782, 1767, 250, 3568,
79, 219, 855, 12009, 395, 1552, 705, 2282, 84, 3396, 252, 2058,
1480, 5, 745, 2573, 1005, 946, 3320, 5406, 2192, 20, 1207, 9519,
66, 463, 250, 1095, 16556, 88, 2695, 275, 16, 1577, 29, 3221,
25, 6295, 2, 63, 123, 8, 1, 37, 5308, 4546, 994, 4567, 421, 0,
1938, 19480, 1027, 3474, 1982, 2819, 69, 27733, 2152, 15429,
996, 8, 3435, 8748, 17062, 269, 26188, 35823, 2572, 67, 761,
13493, 1, 1, 1, 16, 9, 29, 89, 20, 11, 21644, 3, 37, 13, 0, 0,
0, 0, 3, 30, 19, 0, 0, 242, 7246, 1, 20081, 77, 0, 0, 0, 5878,
0, 0, 22, 2, 4, 1, 93, 12, 2, 73, 0, 19, 0, 0, 2, 48, 3, 0, 0,
0, 0, 22, 4, 0, 0, 0, 0, 0, 0, 1, 87, 0, 0, 3, 0, 0, 4, 1, 0,
82, 7, 0, 0, 0, 7, 22, 34, 17, 0, 0, 0, 0, 0, 2, 19, 3, 0, 990,
0, 0, 0, 0, 84, 9, 0, 5, 1246, 1944, 633, 23640, 262, 5399, 83,
19, 4417, 125, 7801, 69, 6755, 6, 39, 262), i.water_content_percent_es = c(98,
39, 85, 14, 21, 28, 50, 83, 21, 59, 20, 66, 61, 70, 46, 23, 8,
17, 10, 75, 52, 13, 9, 8, 47, 8, 8, 46, 86, 24, 17, 31, 35, 19,
32, 40, 79, 22, 49, 91, 15, 90, 63, 90, 60, 53, 29, 91, 98, 39,
85, 14, 21, 28, 50, 83, 21, 59, 20, 66, 61, 70, 46, 23, 8, 17,
10, 75, 52, 13, 9, 8, 47, 8, 8, 46, 86, 24, 17, 39, 85, 14, 21,
28, 50, 83, 21, 59, 20, 66, 61, 70, 46, 98, 23, 8, 17, 10, 75,
52, 13, 9, 8, 47, 8, 8, 46, 86, 24, 17, 31, 35, 19, 32, 40, 79,
22, 49, 91, 15, 90, 63, 90, 60, 53, 29, 91, 98, 39, 85, 14, 21,
28, 50, 83, 21, 59, 20, 66, 61, 70, 46, 23, 8, 17, 10, 75, 52,
13, 9, 8, 47, 8, 8, 46, 86, 24, 17, 31, 35, 19, 32, 40, 79, 22,
49, 91, 15, 90, 63, 90, 60, 53, 29, 91, 31, 35, 19, 32, 40, 79,
22, 49, 91, 15, 90, 63, 90, 60, 53, 29, 91), daysincubated4 = c(0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 24, 24, 24, 24,
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 116, 116, 116,
116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116,
116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116,
116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116,
116, 116, 116, 116, 116, 116, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4), days = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
24, 24, 24, 24, 116, 116, 116, 116, 116, 116, 116, 116, 116,
116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116,
116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116,
116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4), water_content = c(98,
39, 85, 14, 21, 28, 50, 83, 21, 59, 20, 66, 61, 70, 46, 23, 8,
17, 10, 75, 52, 13, 9, 8, 47, 8, 8, 46, 86, 24, 17, 31, 35, 19,
32, 40, 79, 22, 49, 91, 15, 90, 63, 90, 60, 53, 29, 91, 98, 39,
85, 14, 21, 28, 50, 83, 21, 59, 20, 66, 61, 70, 46, 23, 8, 17,
10, 75, 52, 13, 9, 8, 47, 8, 8, 46, 86, 24, 17, 39, 85, 14, 21,
28, 50, 83, 21, 59, 20, 66, 61, 70, 46, 98, 23, 8, 17, 10, 75,
52, 13, 9, 8, 47, 8, 8, 46, 86, 24, 17, 31, 35, 19, 32, 40, 79,
22, 49, 91, 15, 90, 63, 90, 60, 53, 29, 91, 98, 39, 85, 14, 21,
28, 50, 83, 21, 59, 20, 66, 61, 70, 46, 23, 8, 17, 10, 75, 52,
13, 9, 8, 47, 8, 8, 46, 86, 24, 17, 31, 35, 19, 32, 40, 79, 22,
49, 91, 15, 90, 63, 90, 60, 53, 29, 91, 31, 35, 19, 32, 40, 79,
22, 49, 91, 15, 90, 63, 90, 60, 53, 29, 91), acetone = c(22,
17, 11, 1782, 1767, 250, 3568, 79, 219, 855, 12009, 395, 1552,
705, 2282, 84, 3396, 252, 2058, 1480, 5, 745, 2573, 1005, 946,
3320, 5406, 2192, 20, 1207, 9519, 66, 463, 250, 1095, 16556,
88, 2695, 275, 16, 1577, 29, 3221, 25, 6295, 2, 63, 123, 8, 1,
37, 5308, 4546, 994, 4567, 421, 0, 1938, 19480, 1027, 3474, 1982,
2819, 69, 27733, 2152, 15429, 996, 8, 3435, 8748, 17062, 269,
26188, 35823, 2572, 67, 761, 13493, 1, 1, 1, 16, 9, 29, 89, 20,
11, 21644, 3, 37, 13, 0, 0, 0, 0, 3, 30, 19, 0, 0, 242, 7246,
1, 20081, 77, 0, 0, 0, 5878, 0, 0, 22, 2, 4, 1, 93, 12, 2, 73,
0, 19, 0, 0, 2, 48, 3, 0, 0, 0, 0, 22, 4, 0, 0, 0, 0, 0, 0, 1,
87, 0, 0, 3, 0, 0, 4, 1, 0, 82, 7, 0, 0, 0, 7, 22, 34, 17, 0,
0, 0, 0, 0, 2, 19, 3, 0, 990, 0, 0, 0, 0, 84, 9, 0, 5, 1246,
1944, 633, 23640, 262, 5399, 83, 19, 4417, 125, 7801, 69, 6755,
6, 39, 262)), row.names = c(NA, -192L), class = "data.frame")
and the code for the graph I've made is:
library(ggpmisc)
library(tidyverse)
formula <- y~x
ggplot(df, aes(water_content, acetone)) +
geom_point() +
geom_smooth(method = "lm",formula = y~x) +
theme_bw()+
facet_wrap(~days, scales = "free")+
stat_poly_eq(
aes(label = paste(stat(adj.rr.label), stat(eq.label), stat(p.value.label), sep = "*\", \"*")),
formula = formula, parse = TRUE, size=3)
Any ideas why I don't get the same slope values?
All help is much appreciated!
You swapped x and y. Possibly because of using complex 'tidyverse' coding this was not obvious.
library(nlme)
lmList(acetone ~ water_content | days, data = df)
gives
Call:
Model: acetone ~ water_content | days
Data: df
Coefficients:
(Intercept) water_content
0 3314.26811 -31.663431
4 12046.87296 -154.277916
24 3103.13075 -44.368527
116 63.82385 -0.792739
Degrees of freedom: 192 total; 184 residual
Residual standard error: 4538.636
I visualized a edgelist network with the network() function in R. It's a small network with about 100 nodes and about 130 edges and it has a couple of clusters where nodes are packed in pretty closely.
I'd like to be able to interact with the graphic so that I can zoom in and look at particular clusters of nodes.
I tried using plotly with this code
library(network)
net1 <-
network(netmat1_matrix, matrix.type = "edgelist", loops = T)
ggplotly(net1)
How do I use plotly, or a similar interactive graphics software, to interact with Networks in R?
You can use the following code to achieve that
library(network)
library(plotly)
library(GGally)
library(sna)
summary(netmat1_matrix)
#> a b c
#> Min. : 1.00 Min. : 1.00 Min. : 1.000
#> 1st Qu.: 23.00 1st Qu.: 44.00 1st Qu.: 1.000
#> Median : 62.00 Median : 95.50 Median : 1.000
#> Mean : 72.93 Mean : 97.18 Mean : 5.328
#> 3rd Qu.:114.00 3rd Qu.:144.00 3rd Qu.: 3.000
#> Max. :209.00 Max. :209.00 Max. :246.000
#> NA's :1
df <- na.omit(netmat1_matrix)
summary(df)
#> a b c
#> Min. : 1.00 Min. : 1.00 Min. : 1.000
#> 1st Qu.: 23.00 1st Qu.: 44.00 1st Qu.: 1.000
#> Median : 62.00 Median : 95.50 Median : 1.000
#> Mean : 72.95 Mean : 97.18 Mean : 5.332
#> 3rd Qu.:114.00 3rd Qu.:144.00 3rd Qu.: 3.000
#> Max. :209.00 Max. :209.00 Max. :246.000
net1 <- network(df, matrix.type = "edgelist", loops = T)
try <- ggnet2(net1, node.size = 1, node.color = "black",
edge.size = 1, edge.color = "grey")
ggplotly(try)
I have used the data provided by you in this question
netmat1_matrix = structure(c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 12, 12,
12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13,
13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15,
15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16,
17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18,
18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19,
19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
22, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 24, 24,
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26,
26, 26, 27, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29,
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 30, 30, 30, 30, 30,
31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 33, 33, 34,
34, 34, 34, 34, 34, 34, 34, 34, 34, 35, 35, 35, 35, 35, 36, 36,
36, 36, 36, 37, 37, 37, 38, 38, 38, 39, 39, 39, 39, 39, 39, 39,
39, 39, 39, 40, 40, 40, 40, 41, 41, 41, 42, 42, 42, 42, 42, 42,
42, 42, 43, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44,
44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 45, 45, 45,
45, 45, 45, 45, 45, 46, 46, 47, 47, 47, 47, 47, 47, 47, 47, 48,
49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 50, 50, 50, 50,
50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 51, 51, 51, 51, 51, 52,
52, 52, 52, 52, 52, 52, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53,
53, 53, 54, 54, 54, 54, 54, 54, 54, 54, 54, 55, 55, 55, 55, 55,
55, 55, 55, 55, 56, 56, 56, 56, 56, 56, 56, 56, 57, 57, 57, 57,
57, 57, 57, 58, 58, 58, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59,
59, 60, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 62, 62, 62,
62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 63, 63, 64, 64, 64,
64, 64, 64, 65, 66, 66, 66, 66, 67, 67, 67, 67, 67, 67, 67, 67,
67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 68,
68, 68, 68, 68, 68, 68, 68, 69, 69, 69, 70, 70, 70, 71, 71, 71,
71, 71, 72, 72, 72, 72, 72, 72, 72, 72, 73, 73, 73, 73, 73, 73,
74, 74, 74, 74, 74, 74, 74, 75, 75, 75, 75, 75, 75, 75, 75, 75,
75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 76, 76, 76, 76, 76,
76, 76, 76, 76, 76, 77, 77, 78, 78, 78, 79, 79, 79, 79, 79, 79,
80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 81, 81, 81,
81, 81, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 83,
83, 83, 83, 83, 84, 85, 86, 86, 86, 86, 86, 86, 86, 86, 87, 87,
87, 88, 88, 88, 89, 89, 89, 89, 89, 89, 89, 90, 90, 90, 90, 90,
90, 90, 90, 90, 90, 90, 91, 91, 91, 91, 91, 91, 92, 92, 92, 92,
93, 93, 93, 93, 93, 93, 93, 93, 94, 94, 94, 95, 95, 95, 95, 95,
96, 96, 96, 97, 97, 97, 97, 97, 97, 98, 98, 98, 98, 98, 99, 99,
99, 99, 99, 100, 100, 100, 100, 101, 101, 101, 101, 102, 102,
103, 103, 104, 104, 105, 105, 105, 106, 106, 106, 106, 106, 107,
107, 108, 108, 108, 108, 108, 108, 108, 108, 109, 109, 109, 109,
109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 110, 110,
110, 110, 110, 111, 111, 112, 112, 113, 113, 113, 113, 113, 114,
114, 114, 114, 114, 114, 114, 114, 114, 114, 115, 115, 115, 115,
115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 116,
116, 117, 117, 117, 117, 118, 119, 119, 119, 119, 120, 120, 120,
121, 121, 121, 121, 121, 121, 121, 122, 122, 122, 122, 123, 123,
124, 124, 124, 125, 125, 125, 125, 125, 125, 125, 126, 126, 126,
126, 127, 127, 127, 127, 127, 127, 127, 127, 128, 128, 128, 128,
129, 129, 129, 129, 130, 130, 130, 131, 131, 132, 132, 132, 132,
132, 132, 133, 133, 133, 133, 133, 133, 133, 133, 134, 134, 134,
134, 135, 135, 136, 136, 137, 138, 139, 139, 139, 140, 140, 140,
140, 140, 141, 141, 141, 141, 141, 141, 141, 142, 142, 142, 142,
142, 143, 143, 144, 144, 144, 144, 144, 144, 144, 145, 145, 145,
146, 146, 146, 147, 147, 148, 148, 149, 149, 149, 150, 150, 150,
150, 150, 151, 151, 151, 151, 151, 151, 151, 151, 151, 152, 152,
152, 152, 153, 153, 153, 153, 154, 154, 155, 155, 155, 155, 155,
155, 156, 156, 156, 156, 157, 157, 158, 158, 158, 159, 159, 159,
159, 159, 160, 161, 161, 162, 162, 163, 163, 163, 163, 163, 164,
164, 165, 165, 165, 165, 165, 165, 166, 166, 166, 167, 167, 167,
167, 168, 168, 168, 168, 169, 170, 171, 171, 172, 172, 172, 172,
173, 173, 173, 174, 174, 175, 175, 175, 175, 175, 176, 177, 177,
177, 177, 178, 179, 180, 181, 181, 181, 182, 183, 183, 183, 183,
183, 184, 184, 185, 185, 186, 187, 187, 187, 187, 188, 188, 188,
189, 189, 190, 190, 191, 191, 191, 192, 192, 193, 193, 194, 194,
195, 195, 196, 197, 197, 197, 198, 198, 199, 200, 201, 202, 203,
203, 204, 205, 205, 206, 206, 207, 208, 209, 1, 27, 28, 58, 108,
120, 161, 178, 181, 208, 2, 6, 18, 97, 104, 140, 3, 10, 17, 23,
28, 42, 45, 92, 100, 102, 111, 113, 148, 167, 175, 178, 180,
183, 194, 4, 31, 34, 62, 63, 72, 79, 98, 155, 162, 166, 187,
3, 5, 27, 37, 47, 102, 110, 131, 154, 164, 2, 6, 52, 68, 97,
104, 139, 140, 150, 157, 165, 5, 7, 116, 131, 180, 8, 11, 22,
35, 51, 55, 60, 64, 65, 71, 88, 95, 107, 118, 124, 138, 154,
177, 9, 21, 25, 44, 45, 49, 54, 59, 90, 93, 94, 96, 129, 186,
198, 3, 10, 13, 17, 32, 42, 47, 61, 77, 92, 93, 96, 100, 113,
122, 131, 148, 151, 156, 158, 175, 183, 195, 11, 60, 107, 12,
13, 15, 18, 20, 25, 29, 74, 76, 109, 121, 141, 144, 173, 206,
10, 13, 14, 15, 44, 59, 62, 67, 75, 76, 97, 109, 122, 128, 141,
144, 173, 184, 186, 189, 198, 13, 14, 40, 44, 54, 67, 68, 75,
76, 77, 83, 109, 119, 123, 137, 141, 142, 144, 151, 155, 168,
204, 206, 15, 19, 26, 28, 40, 82, 83, 98, 99, 108, 120, 126,
140, 181, 8, 16, 22, 45, 64, 65, 95, 138, 177, 3, 17, 33, 36,
48, 100, 113, 6, 12, 18, 20, 26, 29, 30, 72, 75, 79, 98, 105,
109, 119, 123, 129, 133, 140, 141, 152, 192, 204, 15, 19, 40,
41, 99, 134, 139, 2, 19, 20, 54, 57, 72, 80, 90, 129, 133, 134,
137, 139, 188, 192, 203, 4, 9, 12, 13, 16, 21, 23, 24, 45, 49,
50, 54, 94, 114, 198, 22, 35, 51, 55, 65, 71, 78, 85, 88, 107,
118, 124, 138, 154, 23, 44, 49, 50, 76, 97, 109, 112, 130, 141,
144, 151, 195, 13, 14, 24, 29, 44, 62, 67, 75, 76, 83, 109, 114,
128, 137, 139, 141, 144, 149, 153, 189, 193, 206, 13, 14, 25,
109, 128, 173, 184, 193, 2, 12, 18, 26, 72, 75, 27, 3, 28, 103,
108, 120, 208, 14, 24, 29, 67, 75, 83, 109, 114, 115, 121, 125,
137, 141, 142, 153, 196, 202, 204, 9, 16, 30, 101, 139, 31, 114,
149, 165, 166, 173, 191, 193, 198, 17, 32, 36, 37, 33, 43, 34,
44, 54, 62, 72, 98, 162, 164, 166, 189, 1, 35, 50, 91, 170, 17,
36, 41, 48, 131, 32, 37, 158, 38, 90, 192, 20, 21, 26, 39, 70,
87, 90, 94, 155, 171, 15, 19, 40, 148, 41, 116, 163, 3, 7, 10,
42, 47, 102, 131, 148, 43, 4, 9, 13, 16, 21, 23, 24, 25, 34,
44, 49, 50, 54, 59, 67, 82, 84, 91, 97, 106, 109, 134, 144, 186,
189, NA, 21, 45, 62, 110, 151, 162, 206, 209, 46, 164, 36, 37,
42, 47, 93, 100, 113, 132, 48, 2, 6, 12, 15, 18, 19, 20, 26,
29, 38, 44, 49, 53, 56, 74, 75, 79, 86, 94, 105, 121, 129, 130,
133, 150, 157, 172, 190, 6, 34, 35, 44, 50, 52, 54, 59, 97, 123,
133, 156, 157, 189, 11, 51, 55, 88, 118, 6, 18, 50, 52, 125,
157, 159, 13, 15, 18, 20, 53, 57, 89, 123, 130, 168, 188, 204,
9, 16, 30, 34, 54, 90, 97, 129, 198, 41, 51, 55, 71, 116, 124,
156, 163, 193, 56, 106, 121, 159, 184, 187, 191, 192, 13, 40,
53, 57, 75, 123, 204, 28, 58, 120, 13, 44, 59, 68, 76, 77, 96,
114, 141, 144, 195, 60, 10, 30, 49, 61, 77, 93, 100, 145, 154,
172, 209, 22, 24, 30, 45, 54, 62, 98, 110, 149, 151, 162, 166,
189, 206, 63, 204, 8, 22, 64, 95, 138, 161, 65, 47, 66, 116,
145, 13, 14, 24, 29, 44, 49, 55, 62, 67, 75, 76, 97, 109, 114,
125, 137, 139, 141, 144, 163, 189, 193, 206, 14, 68, 77, 81,
113, 136, 179, 195, 69, 113, 158, 39, 70, 171, 71, 78, 88, 107,
124, 26, 34, 62, 72, 79, 86, 98, 139, 73, 77, 81, 106, 181, 197,
49, 59, 74, 89, 172, 188, 201, 12, 14, 18, 24, 26, 29, 53, 67,
75, 83, 114, 115, 121, 123, 125, 141, 142, 153, 196, 204, 25,
44, 49, 76, 114, 141, 144, 173, 193, 198, 59, 77, 8, 22, 78,
26, 29, 63, 79, 98, 153, 12, 13, 18, 25, 74, 80, 82, 105, 130,
173, 184, 188, 199, 14, 73, 81, 172, 179, 44, 50, 62, 76, 82,
109, 121, 139, 141, 144, 156, 189, 203, 29, 67, 83, 115, 137,
84, 85, 4, 31, 40, 63, 79, 86, 155, 187, 39, 87, 94, 71, 88,
118, 18, 57, 74, 89, 97, 141, 188, 54, 90, 94, 98, 105, 123,
129, 133, 188, 189, 200, 9, 16, 21, 54, 91, 134, 92, 148, 158,
176, 10, 46, 93, 97, 113, 158, 189, 195, 87, 94, 192, 8, 64,
95, 124, 138, 49, 96, 197, 76, 89, 97, 141, 144, 150, 18, 34,
79, 98, 162, 15, 40, 90, 91, 99, 10, 69, 100, 113, 30, 90, 101,
129, 3, 102, 28, 103, 15, 104, 105, 168, 188, 13, 56, 106, 184,
192, 11, 107, 27, 28, 58, 108, 130, 161, 181, 208, 12, 24, 25,
29, 44, 49, 59, 67, 76, 82, 109, 114, 144, 198, 206, 45, 62,
110, 151, 209, 111, 167, 112, 182, 47, 48, 93, 113, 197, 24,
29, 76, 114, 137, 149, 173, 191, 193, 198, 14, 24, 29, 67, 75,
83, 114, 115, 121, 125, 137, 142, 153, 196, 202, 204, 41, 116,
64, 84, 117, 170, 118, 102, 119, 144, 189, 28, 63, 120, 13, 56,
82, 99, 106, 121, 123, 10, 122, 160, 175, 74, 123, 7, 8, 124,
56, 115, 125, 153, 193, 196, 204, 40, 104, 126, 174, 9, 12, 13,
16, 21, 23, 24, 49, 47, 55, 93, 128, 30, 90, 129, 139, 112, 130,
133, 36, 131, 17, 36, 47, 48, 113, 132, 52, 90, 98, 123, 133,
136, 157, 179, 20, 54, 134, 190, 120, 135, 87, 136, 137, 138,
18, 19, 139, 18, 30, 94, 140, 190, 6, 56, 94, 123, 129, 139,
141, 14, 29, 75, 142, 153, 143, 189, 14, 16, 68, 83, 137, 144,
203, 41, 66, 145, 51, 146, 177, 147, 176, 148, 175, 149, 189,
193, 97, 130, 139, 141, 150, 10, 62, 76, 77, 122, 151, 175, 182,
206, 18, 101, 139, 152, 114, 115, 125, 153, 49, 154, 4, 20, 90,
155, 168, 184, 10, 76, 93, 156, 30, 157, 14, 96, 158, 20, 72,
98, 159, 190, 160, 120, 161, 62, 162, 51, 55, 116, 128, 163,
27, 46, 44, 76, 97, 141, 144, 165, 31, 76, 166, 3, 10, 111, 167,
105, 168, 184, 200, 169, 170, 70, 171, 77, 81, 93, 172, 109,
173, 198, 99, 174, 111, 148, 175, 183, 194, 176, 107, 135, 146,
177, 178, 179, 180, 28, 108, 181, 182, 10, 175, 180, 183, 194,
130, 184, 18, 185, 186, 2, 4, 159, 187, 68, 188, 201, 143, 189,
174, 190, 56, 166, 191, 80, 192, 76, 193, 3, 194, 68, 77, 196,
17, 77, 197, 21, 198, 199, 200, 201, 202, 136, 203, 204, 110,
139, 151, 206, 207, 28, 209, 36, 2, 4, 5, 6, 2, 2, 1, 1, 2, 246,
3, 1, 2, 4, 2, 47, 7, 3, 1, 1, 3, 1, 1, 4, 5, 9, 2, 3, 8, 1,
1, 10, 4, 1, 88, 2, 1, 1, 2, 1, 3, 1, 2, 1, 1, 1, 1, 18, 1, 1,
5, 5, 1, 1, 1, 4, 15, 65, 6, 2, 1, 2, 1, 2, 1, 2, 2, 1, 51, 2,
1, 9, 37, 2, 2, 2, 2, 2, 2,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 2, 7, 1, 14, 1, 1, 12, 1, 1, 1, 6, 1, 8, 2, 2,
2, 16, 1, 1, 1, 2, 10, 2, 1, 1, 1, 1, 1, 1, 10, 1, 1, 11, 1,
1, 4, 7, 1, 8, 1, 1, 14, 11, 3, 7, 1, 1, 1, 11, 1, 12, 1, 1,
11, 1, 3, 5, 1, 1, 4, 1, 1, 1, 7, 10, 12, 6, 1, 2, 6, 8, 2, 1,
1, 4, 1, 1, 6, 1, 8, 4, 1, 2, 1, 2, 1, 4, 1, 1, 2, 1, 3, 1, 1,
4, 1, 4, 2, 1, 3, 1, 2, 2, 5, 1, 2, 1, 1, 3, 5, 5, 4, 4, 1, 2,
1, 1, 1, 1, 1, 1, 1, 2), .Dim = c(1227L, 3L), .Dimnames = list(
NULL, c("a", "b", "c")))
if you want some interactive network, I would look into networkD3 and visNetwork. You can use both libraries in combination with shiny (if that's what you are looking for?).
Both libraries have a lot of parameters to adjust. As it has a close connection to igraph/tidygraph and you can chose different layouts and stuff I like the visNetwork library better ... on the ohter handside ... somtimes the networkD3 looks better :D
Anyways ... here is some sample code to give you a hint how they work ...
# Init ====
"%>%" <- magrittr::"%>%"
# Some data ====
dat <- dplyr::tibble(source=paste0("ID_",1:100),
target=paste0("ID_",sample(1:100,size=100,replace=T))) %>%
dplyr::filter(source!=target) %>%
dplyr::distinct(source,target) %>%
dplyr::mutate(weight=sample(1:30,size=nrow(.),replace=T))
# networkD3 ====
# simple network with networkD3 ----
networkD3::simpleNetwork(dat,
Source=1,
Target=2,
charge=dat$WEIGHT)
# More complex network with networkD3 ----
# modify data
g <- dat %>%
tidygraph::as_tbl_graph(directed=FALSE) %>%
tidygraph::activate(nodes) %>%
tidygraph::mutate(grp=tidygraph::group_infomap(),
size=tidygraph::centrality_betweenness()) %>%
tidygraph::activate(edges)
nodes <- g %>%
tidygraph::activate(nodes) %>%
tidygraph::as_tibble()
edges <- g %>%
tidygraph::activate(edges) %>%
tidygraph::as_tibble() %>%
# index starts from 0 (javascript)
dplyr::mutate(from=from-1,to=to-1)
# visualize data
networkD3::forceNetwork(Links=edges,
Nodes=nodes,
Source="from",
Target="to",
Value="weight",
NodeID="name",
Group="grp",
Nodesize="size",
opacity=0.8,
zoom=T)
# visNetwork ====
# modify data
ig <- g %>%
tidygraph::activate(nodes) %>%
tidygraph::mutate(size=size/10) %>%
tidygraph::mutate(groups=sample(LETTERS[1:3],size=tidygraph::graph_size(),replace=T),
color=sample(c("red","blue","green"),size=tidygraph::graph_size(),replace=T)) %>%
tidygraph::as.igraph()
# visualize data
visNetwork::visIgraph(ig) %>%
visNetwork::visIgraphLayout(layout="layout_with_fr")
I'd like to make a network that has labels for each of the nodes.
Each of the nodes is represented by a two letter string and that's what I want to visualize.
My data is below where the first two columns should be strings and the last column is a value
I tried this code
library(network)
network(netmat1_matrix, matrix.type = "edgelist")
But it gave me this error
Error in round(n) : non-numeric argument to mathematical function
It works when I use this data below, but not when I replace the first two cols with strings
netmat1_matrix = structure(c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 12, 12,
12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13,
13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15,
15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16,
17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18,
18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19,
19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
22, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 24, 24,
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26,
26, 26, 27, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29,
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 30, 30, 30, 30, 30,
31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 33, 33, 34,
34, 34, 34, 34, 34, 34, 34, 34, 34, 35, 35, 35, 35, 35, 36, 36,
36, 36, 36, 37, 37, 37, 38, 38, 38, 39, 39, 39, 39, 39, 39, 39,
39, 39, 39, 40, 40, 40, 40, 41, 41, 41, 42, 42, 42, 42, 42, 42,
42, 42, 43, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44,
44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 45, 45, 45,
45, 45, 45, 45, 45, 46, 46, 47, 47, 47, 47, 47, 47, 47, 47, 48,
49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 50, 50, 50, 50,
50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 51, 51, 51, 51, 51, 52,
52, 52, 52, 52, 52, 52, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53,
53, 53, 54, 54, 54, 54, 54, 54, 54, 54, 54, 55, 55, 55, 55, 55,
55, 55, 55, 55, 56, 56, 56, 56, 56, 56, 56, 56, 57, 57, 57, 57,
57, 57, 57, 58, 58, 58, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59,
59, 60, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 62, 62, 62,
62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 63, 63, 64, 64, 64,
64, 64, 64, 65, 66, 66, 66, 66, 67, 67, 67, 67, 67, 67, 67, 67,
67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 68,
68, 68, 68, 68, 68, 68, 68, 69, 69, 69, 70, 70, 70, 71, 71, 71,
71, 71, 72, 72, 72, 72, 72, 72, 72, 72, 73, 73, 73, 73, 73, 73,
74, 74, 74, 74, 74, 74, 74, 75, 75, 75, 75, 75, 75, 75, 75, 75,
75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 76, 76, 76, 76, 76,
76, 76, 76, 76, 76, 77, 77, 78, 78, 78, 79, 79, 79, 79, 79, 79,
80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 81, 81, 81,
81, 81, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 83,
83, 83, 83, 83, 84, 85, 86, 86, 86, 86, 86, 86, 86, 86, 87, 87,
87, 88, 88, 88, 89, 89, 89, 89, 89, 89, 89, 90, 90, 90, 90, 90,
90, 90, 90, 90, 90, 90, 91, 91, 91, 91, 91, 91, 92, 92, 92, 92,
93, 93, 93, 93, 93, 93, 93, 93, 94, 94, 94, 95, 95, 95, 95, 95,
96, 96, 96, 97, 97, 97, 97, 97, 97, 98, 98, 98, 98, 98, 99, 99,
99, 99, 99, 100, 100, 100, 100, 101, 101, 101, 101, 102, 102,
103, 103, 104, 104, 105, 105, 105, 106, 106, 106, 106, 106, 107,
107, 108, 108, 108, 108, 108, 108, 108, 108, 109, 109, 109, 109,
109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 110, 110,
110, 110, 110, 111, 111, 112, 112, 113, 113, 113, 113, 113, 114,
114, 114, 114, 114, 114, 114, 114, 114, 114, 115, 115, 115, 115,
115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 116,
116, 117, 117, 117, 117, 118, 119, 119, 119, 119, 120, 120, 120,
121, 121, 121, 121, 121, 121, 121, 122, 122, 122, 122, 123, 123,
124, 124, 124, 125, 125, 125, 125, 125, 125, 125, 126, 126, 126,
126, 127, 127, 127, 127, 127, 127, 127, 127, 128, 128, 128, 128,
129, 129, 129, 129, 130, 130, 130, 131, 131, 132, 132, 132, 132,
132, 132, 133, 133, 133, 133, 133, 133, 133, 133, 134, 134, 134,
134, 135, 135, 136, 136, 137, 138, 139, 139, 139, 140, 140, 140,
140, 140, 141, 141, 141, 141, 141, 141, 141, 142, 142, 142, 142,
142, 143, 143, 144, 144, 144, 144, 144, 144, 144, 145, 145, 145,
146, 146, 146, 147, 147, 148, 148, 149, 149, 149, 150, 150, 150,
150, 150, 151, 151, 151, 151, 151, 151, 151, 151, 151, 152, 152,
152, 152, 153, 153, 153, 153, 154, 154, 155, 155, 155, 155, 155,
155, 156, 156, 156, 156, 157, 157, 158, 158, 158, 159, 159, 159,
159, 159, 160, 161, 161, 162, 162, 163, 163, 163, 163, 163, 164,
164, 165, 165, 165, 165, 165, 165, 166, 166, 166, 167, 167, 167,
167, 168, 168, 168, 168, 169, 170, 171, 171, 172, 172, 172, 172,
173, 173, 173, 174, 174, 175, 175, 175, 175, 175, 176, 177, 177,
177, 177, 178, 179, 180, 181, 181, 181, 182, 183, 183, 183, 183,
183, 184, 184, 185, 185, 186, 187, 187, 187, 187, 188, 188, 188,
189, 189, 190, 190, 191, 191, 191, 192, 192, 193, 193, 194, 194,
195, 195, 196, 197, 197, 197, 198, 198, 199, 200, 201, 202, 203,
203, 204, 205, 205, 206, 206, 207, 208, 209, 1, 27, 28, 58, 108,
120, 161, 178, 181, 208, 2, 6, 18, 97, 104, 140, 3, 10, 17, 23,
28, 42, 45, 92, 100, 102, 111, 113, 148, 167, 175, 178, 180,
183, 194, 4, 31, 34, 62, 63, 72, 79, 98, 155, 162, 166, 187,
3, 5, 27, 37, 47, 102, 110, 131, 154, 164, 2, 6, 52, 68, 97,
104, 139, 140, 150, 157, 165, 5, 7, 116, 131, 180, 8, 11, 22,
35, 51, 55, 60, 64, 65, 71, 88, 95, 107, 118, 124, 138, 154,
177, 9, 21, 25, 44, 45, 49, 54, 59, 90, 93, 94, 96, 129, 186,
198, 3, 10, 13, 17, 32, 42, 47, 61, 77, 92, 93, 96, 100, 113,
122, 131, 148, 151, 156, 158, 175, 183, 195, 11, 60, 107, 12,
13, 15, 18, 20, 25, 29, 74, 76, 109, 121, 141, 144, 173, 206,
10, 13, 14, 15, 44, 59, 62, 67, 75, 76, 97, 109, 122, 128, 141,
144, 173, 184, 186, 189, 198, 13, 14, 40, 44, 54, 67, 68, 75,
76, 77, 83, 109, 119, 123, 137, 141, 142, 144, 151, 155, 168,
204, 206, 15, 19, 26, 28, 40, 82, 83, 98, 99, 108, 120, 126,
140, 181, 8, 16, 22, 45, 64, 65, 95, 138, 177, 3, 17, 33, 36,
48, 100, 113, 6, 12, 18, 20, 26, 29, 30, 72, 75, 79, 98, 105,
109, 119, 123, 129, 133, 140, 141, 152, 192, 204, 15, 19, 40,
41, 99, 134, 139, 2, 19, 20, 54, 57, 72, 80, 90, 129, 133, 134,
137, 139, 188, 192, 203, 4, 9, 12, 13, 16, 21, 23, 24, 45, 49,
50, 54, 94, 114, 198, 22, 35, 51, 55, 65, 71, 78, 85, 88, 107,
118, 124, 138, 154, 23, 44, 49, 50, 76, 97, 109, 112, 130, 141,
144, 151, 195, 13, 14, 24, 29, 44, 62, 67, 75, 76, 83, 109, 114,
128, 137, 139, 141, 144, 149, 153, 189, 193, 206, 13, 14, 25,
109, 128, 173, 184, 193, 2, 12, 18, 26, 72, 75, 27, 3, 28, 103,
108, 120, 208, 14, 24, 29, 67, 75, 83, 109, 114, 115, 121, 125,
137, 141, 142, 153, 196, 202, 204, 9, 16, 30, 101, 139, 31, 114,
149, 165, 166, 173, 191, 193, 198, 17, 32, 36, 37, 33, 43, 34,
44, 54, 62, 72, 98, 162, 164, 166, 189, 1, 35, 50, 91, 170, 17,
36, 41, 48, 131, 32, 37, 158, 38, 90, 192, 20, 21, 26, 39, 70,
87, 90, 94, 155, 171, 15, 19, 40, 148, 41, 116, 163, 3, 7, 10,
42, 47, 102, 131, 148, 43, 4, 9, 13, 16, 21, 23, 24, 25, 34,
44, 49, 50, 54, 59, 67, 82, 84, 91, 97, 106, 109, 134, 144, 186,
189, 44, 21, 45, 62, 110, 151, 162, 206, 209, 46, 164, 36, 37,
42, 47, 93, 100, 113, 132, 48, 2, 6, 12, 15, 18, 19, 20, 26,
29, 38, 44, 49, 53, 56, 74, 75, 79, 86, 94, 105, 121, 129, 130,
133, 150, 157, 172, 190, 6, 34, 35, 44, 50, 52, 54, 59, 97, 123,
133, 156, 157, 189, 11, 51, 55, 88, 118, 6, 18, 50, 52, 125,
157, 159, 13, 15, 18, 20, 53, 57, 89, 123, 130, 168, 188, 204,
9, 16, 30, 34, 54, 90, 97, 129, 198, 41, 51, 55, 71, 116, 124,
156, 163, 193, 56, 106, 121, 159, 184, 187, 191, 192, 13, 40,
53, 57, 75, 123, 204, 28, 58, 120, 13, 44, 59, 68, 76, 77, 96,
114, 141, 144, 195, 60, 10, 30, 49, 61, 77, 93, 100, 145, 154,
172, 209, 22, 24, 30, 45, 54, 62, 98, 110, 149, 151, 162, 166,
189, 206, 63, 204, 8, 22, 64, 95, 138, 161, 65, 47, 66, 116,
145, 13, 14, 24, 29, 44, 49, 55, 62, 67, 75, 76, 97, 109, 114,
125, 137, 139, 141, 144, 163, 189, 193, 206, 14, 68, 77, 81,
113, 136, 179, 195, 69, 113, 158, 39, 70, 171, 71, 78, 88, 107,
124, 26, 34, 62, 72, 79, 86, 98, 139, 73, 77, 81, 106, 181, 197,
49, 59, 74, 89, 172, 188, 201, 12, 14, 18, 24, 26, 29, 53, 67,
75, 83, 114, 115, 121, 123, 125, 141, 142, 153, 196, 204, 25,
44, 49, 76, 114, 141, 144, 173, 193, 198, 59, 77, 8, 22, 78,
26, 29, 63, 79, 98, 153, 12, 13, 18, 25, 74, 80, 82, 105, 130,
173, 184, 188, 199, 14, 73, 81, 172, 179, 44, 50, 62, 76, 82,
109, 121, 139, 141, 144, 156, 189, 203, 29, 67, 83, 115, 137,
84, 85, 4, 31, 40, 63, 79, 86, 155, 187, 39, 87, 94, 71, 88,
118, 18, 57, 74, 89, 97, 141, 188, 54, 90, 94, 98, 105, 123,
129, 133, 188, 189, 200, 9, 16, 21, 54, 91, 134, 92, 148, 158,
176, 10, 46, 93, 97, 113, 158, 189, 195, 87, 94, 192, 8, 64,
95, 124, 138, 49, 96, 197, 76, 89, 97, 141, 144, 150, 18, 34,
79, 98, 162, 15, 40, 90, 91, 99, 10, 69, 100, 113, 30, 90, 101,
129, 3, 102, 28, 103, 15, 104, 105, 168, 188, 13, 56, 106, 184,
192, 11, 107, 27, 28, 58, 108, 130, 161, 181, 208, 12, 24, 25,
29, 44, 49, 59, 67, 76, 82, 109, 114, 144, 198, 206, 45, 62,
110, 151, 209, 111, 167, 112, 182, 47, 48, 93, 113, 197, 24,
29, 76, 114, 137, 149, 173, 191, 193, 198, 14, 24, 29, 67, 75,
83, 114, 115, 121, 125, 137, 142, 153, 196, 202, 204, 41, 116,
64, 84, 117, 170, 118, 102, 119, 144, 189, 28, 63, 120, 13, 56,
82, 99, 106, 121, 123, 10, 122, 160, 175, 74, 123, 7, 8, 124,
56, 115, 125, 153, 193, 196, 204, 40, 104, 126, 174, 9, 12, 13,
16, 21, 23, 24, 49, 47, 55, 93, 128, 30, 90, 129, 139, 112, 130,
133, 36, 131, 17, 36, 47, 48, 113, 132, 52, 90, 98, 123, 133,
136, 157, 179, 20, 54, 134, 190, 120, 135, 87, 136, 137, 138,
18, 19, 139, 18, 30, 94, 140, 190, 6, 56, 94, 123, 129, 139,
141, 14, 29, 75, 142, 153, 143, 189, 14, 16, 68, 83, 137, 144,
203, 41, 66, 145, 51, 146, 177, 147, 176, 148, 175, 149, 189,
193, 97, 130, 139, 141, 150, 10, 62, 76, 77, 122, 151, 175, 182,
206, 18, 101, 139, 152, 114, 115, 125, 153, 49, 154, 4, 20, 90,
155, 168, 184, 10, 76, 93, 156, 30, 157, 14, 96, 158, 20, 72,
98, 159, 190, 160, 120, 161, 62, 162, 51, 55, 116, 128, 163,
27, 46, 44, 76, 97, 141, 144, 165, 31, 76, 166, 3, 10, 111, 167,
105, 168, 184, 200, 169, 170, 70, 171, 77, 81, 93, 172, 109,
173, 198, 99, 174, 111, 148, 175, 183, 194, 176, 107, 135, 146,
177, 178, 179, 180, 28, 108, 181, 182, 10, 175, 180, 183, 194,
130, 184, 18, 185, 186, 2, 4, 159, 187, 68, 188, 201, 143, 189,
174, 190, 56, 166, 191, 80, 192, 76, 193, 3, 194, 68, 77, 196,
17, 77, 197, 21, 198, 199, 200, 201, 202, 136, 203, 204, 110,
139, 151, 206, 207, 28, 209, 36, 2, 4, 5, 6, 2, 2, 1, 1, 2, 246,
3, 1, 2, 4, 2, 47, 7, 3, 1, 1, 3, 1, 1, 4, 5, 9, 2, 3, 8, 1,
1, 10, 4, 1, 88, 2, 1, 1, 2, 1, 3, 1, 2, 1, 1, 1, 1, 18, 1, 1,
5, 5, 1, 1, 1, 4, 15, 65, 6, 2, 1, 2, 1, 2, 1, 2, 2, 1, 51, 2,
1, 9, 37, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2,
59, 13, 1, 2, 3, 1, 8, 4, 2, 2, 1, 1, 2, 1, 3, 5, 31, 1, 2, 4,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 1, 11, 1,
1, 4, 7, 1, 8, 1, 1, 14, 11, 3, 7, 1, 1, 1, 11, 1, 12, 1, 1,
11, 1, 3, 5, 1, 1, 4, 1, 1, 1, 7, 10, 12, 6, 1, 2, 6, 8, 2, 1,
1, 4, 1, 1, 6, 1, 8, 4, 1, 2, 1, 2, 1, 4, 1, 1, 2, 1, 3, 1, 1,
4, 1, 4, 2, 1, 3, 1, 2, 2, 5, 1, 2, 1, 1, 3, 5, 5, 4, 4, 1, 2,
1, 1, 1, 1, 1, 1, 1, 2), .Dim = c(1227L, 3L), .Dimnames = list(
NULL, c("a", "b", "c")))
A matrix behaves like a vector : all its columns share the same data type.
If the two first columns are character, the last column will also be cast to character. This is what is causing the error you're experiencing.
Instead of using a matrix, you could use a dataframe :
library(network)
net <- as.data.frame(netmat1_matrix)
net$a <- as.character(net$a)
net$b <- as.character(net$b)
class(net$a)
[1] "character"
class(net$c)
[1] "numeric"
# This works
network(net, matrix.type = "edgelist")
Network attributes:
vertices = 209
directed = TRUE
hyper = FALSE
loops = FALSE
multiple = FALSE
bipartite = FALSE
total edges= 1227
missing edges= 0
non-missing edges= 1227
Vertex attribute names:
vertex.names
Edge attribute names not shown
I'd like to make a network diagram using network(). I have an edgelist in a matrix.
I'm getting the error mentioned in the title. The data works when I set a limit to 450 rows, but it fails when I set the limit to 500 rows.
I'm running this code:
library(network)
network(netmat1_matrix, matrix.type = "edgelist")
And I'm getting this error:
Error in if (n < 0) stop("Network objects cannot be of negative order.") : missing value where TRUE/FALSE needed
I'd like to make a network diagram that shows the relationships between these entities
This is my data using dput
structure(c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 12, 12,
12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13,
13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15,
15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16,
17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18,
18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19,
19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
22, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 24, 24,
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26,
26, 26, 27, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29,
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 30, 30, 30, 30, 30,
31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 33, 33, 34,
34, 34, 34, 34, 34, 34, 34, 34, 34, 35, 35, 35, 35, 35, 36, 36,
36, 36, 36, 37, 37, 37, 38, 38, 38, 39, 39, 39, 39, 39, 39, 39,
39, 39, 39, 40, 40, 40, 40, 41, 41, 41, 42, 42, 42, 42, 42, 42,
42, 42, 43, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44,
44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 45, 45, 45,
45, 45, 45, 45, 45, 46, 46, 47, 47, 47, 47, 47, 47, 47, 47, 48,
49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 50, 50, 50, 50,
50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 51, 51, 51, 51, 51, 52,
52, 52, 52, 52, 52, 52, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53,
53, 53, 54, 54, 54, 54, 54, 54, 54, 54, 54, 55, 55, 55, 55, 55,
55, 55, 55, 55, 56, 56, 56, 56, 56, 56, 56, 56, 57, 57, 57, 57,
57, 57, 57, 58, 58, 58, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59,
59, 60, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 62, 62, 62,
62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 63, 63, 64, 64, 64,
64, 64, 64, 65, 66, 66, 66, 66, 67, 67, 67, 67, 67, 67, 67, 67,
67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 68,
68, 68, 68, 68, 68, 68, 68, 69, 69, 69, 70, 70, 70, 71, 71, 71,
71, 71, 72, 72, 72, 72, 72, 72, 72, 72, 73, 73, 73, 73, 73, 73,
74, 74, 74, 74, 74, 74, 74, 75, 75, 75, 75, 75, 75, 75, 75, 75,
75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 76, 76, 76, 76, 76,
76, 76, 76, 76, 76, 77, 77, 78, 78, 78, 79, 79, 79, 79, 79, 79,
80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 81, 81, 81,
81, 81, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 83,
83, 83, 83, 83, 84, 85, 86, 86, 86, 86, 86, 86, 86, 86, 87, 87,
87, 88, 88, 88, 89, 89, 89, 89, 89, 89, 89, 90, 90, 90, 90, 90,
90, 90, 90, 90, 90, 90, 91, 91, 91, 91, 91, 91, 92, 92, 92, 92,
93, 93, 93, 93, 93, 93, 93, 93, 94, 94, 94, 95, 95, 95, 95, 95,
96, 96, 96, 97, 97, 97, 97, 97, 97, 98, 98, 98, 98, 98, 99, 99,
99, 99, 99, 100, 100, 100, 100, 101, 101, 101, 101, 102, 102,
103, 103, 104, 104, 105, 105, 105, 106, 106, 106, 106, 106, 107,
107, 108, 108, 108, 108, 108, 108, 108, 108, 109, 109, 109, 109,
109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 110, 110,
110, 110, 110, 111, 111, 112, 112, 113, 113, 113, 113, 113, 114,
114, 114, 114, 114, 114, 114, 114, 114, 114, 115, 115, 115, 115,
115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 116,
116, 117, 117, 117, 117, 118, 119, 119, 119, 119, 120, 120, 120,
121, 121, 121, 121, 121, 121, 121, 122, 122, 122, 122, 123, 123,
124, 124, 124, 125, 125, 125, 125, 125, 125, 125, 126, 126, 126,
126, 127, 127, 127, 127, 127, 127, 127, 127, 128, 128, 128, 128,
129, 129, 129, 129, 130, 130, 130, 131, 131, 132, 132, 132, 132,
132, 132, 133, 133, 133, 133, 133, 133, 133, 133, 134, 134, 134,
134, 135, 135, 136, 136, 137, 138, 139, 139, 139, 140, 140, 140,
140, 140, 141, 141, 141, 141, 141, 141, 141, 142, 142, 142, 142,
142, 143, 143, 144, 144, 144, 144, 144, 144, 144, 145, 145, 145,
146, 146, 146, 147, 147, 148, 148, 149, 149, 149, 150, 150, 150,
150, 150, 151, 151, 151, 151, 151, 151, 151, 151, 151, 152, 152,
152, 152, 153, 153, 153, 153, 154, 154, 155, 155, 155, 155, 155,
155, 156, 156, 156, 156, 157, 157, 158, 158, 158, 159, 159, 159,
159, 159, 160, 161, 161, 162, 162, 163, 163, 163, 163, 163, 164,
164, 165, 165, 165, 165, 165, 165, 166, 166, 166, 167, 167, 167,
167, 168, 168, 168, 168, 169, 170, 171, 171, 172, 172, 172, 172,
173, 173, 173, 174, 174, 175, 175, 175, 175, 175, 176, 177, 177,
177, 177, 178, 179, 180, 181, 181, 181, 182, 183, 183, 183, 183,
183, 184, 184, 185, 185, 186, 187, 187, 187, 187, 188, 188, 188,
189, 189, 190, 190, 191, 191, 191, 192, 192, 193, 193, 194, 194,
195, 195, 196, 197, 197, 197, 198, 198, 199, 200, 201, 202, 203,
203, 204, 205, 205, 206, 206, 207, 208, 209, 1, 27, 28, 58, 108,
120, 161, 178, 181, 208, 2, 6, 18, 97, 104, 140, 3, 10, 17, 23,
28, 42, 45, 92, 100, 102, 111, 113, 148, 167, 175, 178, 180,
183, 194, 4, 31, 34, 62, 63, 72, 79, 98, 155, 162, 166, 187,
3, 5, 27, 37, 47, 102, 110, 131, 154, 164, 2, 6, 52, 68, 97,
104, 139, 140, 150, 157, 165, 5, 7, 116, 131, 180, 8, 11, 22,
35, 51, 55, 60, 64, 65, 71, 88, 95, 107, 118, 124, 138, 154,
177, 9, 21, 25, 44, 45, 49, 54, 59, 90, 93, 94, 96, 129, 186,
198, 3, 10, 13, 17, 32, 42, 47, 61, 77, 92, 93, 96, 100, 113,
122, 131, 148, 151, 156, 158, 175, 183, 195, 11, 60, 107, 12,
13, 15, 18, 20, 25, 29, 74, 76, 109, 121, 141, 144, 173, 206,
10, 13, 14, 15, 44, 59, 62, 67, 75, 76, 97, 109, 122, 128, 141,
144, 173, 184, 186, 189, 198, 13, 14, 40, 44, 54, 67, 68, 75,
76, 77, 83, 109, 119, 123, 137, 141, 142, 144, 151, 155, 168,
204, 206, 15, 19, 26, 28, 40, 82, 83, 98, 99, 108, 120, 126,
140, 181, 8, 16, 22, 45, 64, 65, 95, 138, 177, 3, 17, 33, 36,
48, 100, 113, 6, 12, 18, 20, 26, 29, 30, 72, 75, 79, 98, 105,
109, 119, 123, 129, 133, 140, 141, 152, 192, 204, 15, 19, 40,
41, 99, 134, 139, 2, 19, 20, 54, 57, 72, 80, 90, 129, 133, 134,
137, 139, 188, 192, 203, 4, 9, 12, 13, 16, 21, 23, 24, 45, 49,
50, 54, 94, 114, 198, 22, 35, 51, 55, 65, 71, 78, 85, 88, 107,
118, 124, 138, 154, 23, 44, 49, 50, 76, 97, 109, 112, 130, 141,
144, 151, 195, 13, 14, 24, 29, 44, 62, 67, 75, 76, 83, 109, 114,
128, 137, 139, 141, 144, 149, 153, 189, 193, 206, 13, 14, 25,
109, 128, 173, 184, 193, 2, 12, 18, 26, 72, 75, 27, 3, 28, 103,
108, 120, 208, 14, 24, 29, 67, 75, 83, 109, 114, 115, 121, 125,
137, 141, 142, 153, 196, 202, 204, 9, 16, 30, 101, 139, 31, 114,
149, 165, 166, 173, 191, 193, 198, 17, 32, 36, 37, 33, 43, 34,
44, 54, 62, 72, 98, 162, 164, 166, 189, 1, 35, 50, 91, 170, 17,
36, 41, 48, 131, 32, 37, 158, 38, 90, 192, 20, 21, 26, 39, 70,
87, 90, 94, 155, 171, 15, 19, 40, 148, 41, 116, 163, 3, 7, 10,
42, 47, 102, 131, 148, 43, 4, 9, 13, 16, 21, 23, 24, 25, 34,
44, 49, 50, 54, 59, 67, 82, 84, 91, 97, 106, 109, 134, 144, 186,
189, NA, 21, 45, 62, 110, 151, 162, 206, 209, 46, 164, 36, 37,
42, 47, 93, 100, 113, 132, 48, 2, 6, 12, 15, 18, 19, 20, 26,
29, 38, 44, 49, 53, 56, 74, 75, 79, 86, 94, 105, 121, 129, 130,
133, 150, 157, 172, 190, 6, 34, 35, 44, 50, 52, 54, 59, 97, 123,
133, 156, 157, 189, 11, 51, 55, 88, 118, 6, 18, 50, 52, 125,
157, 159, 13, 15, 18, 20, 53, 57, 89, 123, 130, 168, 188, 204,
9, 16, 30, 34, 54, 90, 97, 129, 198, 41, 51, 55, 71, 116, 124,
156, 163, 193, 56, 106, 121, 159, 184, 187, 191, 192, 13, 40,
53, 57, 75, 123, 204, 28, 58, 120, 13, 44, 59, 68, 76, 77, 96,
114, 141, 144, 195, 60, 10, 30, 49, 61, 77, 93, 100, 145, 154,
172, 209, 22, 24, 30, 45, 54, 62, 98, 110, 149, 151, 162, 166,
189, 206, 63, 204, 8, 22, 64, 95, 138, 161, 65, 47, 66, 116,
145, 13, 14, 24, 29, 44, 49, 55, 62, 67, 75, 76, 97, 109, 114,
125, 137, 139, 141, 144, 163, 189, 193, 206, 14, 68, 77, 81,
113, 136, 179, 195, 69, 113, 158, 39, 70, 171, 71, 78, 88, 107,
124, 26, 34, 62, 72, 79, 86, 98, 139, 73, 77, 81, 106, 181, 197,
49, 59, 74, 89, 172, 188, 201, 12, 14, 18, 24, 26, 29, 53, 67,
75, 83, 114, 115, 121, 123, 125, 141, 142, 153, 196, 204, 25,
44, 49, 76, 114, 141, 144, 173, 193, 198, 59, 77, 8, 22, 78,
26, 29, 63, 79, 98, 153, 12, 13, 18, 25, 74, 80, 82, 105, 130,
173, 184, 188, 199, 14, 73, 81, 172, 179, 44, 50, 62, 76, 82,
109, 121, 139, 141, 144, 156, 189, 203, 29, 67, 83, 115, 137,
84, 85, 4, 31, 40, 63, 79, 86, 155, 187, 39, 87, 94, 71, 88,
118, 18, 57, 74, 89, 97, 141, 188, 54, 90, 94, 98, 105, 123,
129, 133, 188, 189, 200, 9, 16, 21, 54, 91, 134, 92, 148, 158,
176, 10, 46, 93, 97, 113, 158, 189, 195, 87, 94, 192, 8, 64,
95, 124, 138, 49, 96, 197, 76, 89, 97, 141, 144, 150, 18, 34,
79, 98, 162, 15, 40, 90, 91, 99, 10, 69, 100, 113, 30, 90, 101,
129, 3, 102, 28, 103, 15, 104, 105, 168, 188, 13, 56, 106, 184,
192, 11, 107, 27, 28, 58, 108, 130, 161, 181, 208, 12, 24, 25,
29, 44, 49, 59, 67, 76, 82, 109, 114, 144, 198, 206, 45, 62,
110, 151, 209, 111, 167, 112, 182, 47, 48, 93, 113, 197, 24,
29, 76, 114, 137, 149, 173, 191, 193, 198, 14, 24, 29, 67, 75,
83, 114, 115, 121, 125, 137, 142, 153, 196, 202, 204, 41, 116,
64, 84, 117, 170, 118, 102, 119, 144, 189, 28, 63, 120, 13, 56,
82, 99, 106, 121, 123, 10, 122, 160, 175, 74, 123, 7, 8, 124,
56, 115, 125, 153, 193, 196, 204, 40, 104, 126, 174, 9, 12, 13,
16, 21, 23, 24, 49, 47, 55, 93, 128, 30, 90, 129, 139, 112, 130,
133, 36, 131, 17, 36, 47, 48, 113, 132, 52, 90, 98, 123, 133,
136, 157, 179, 20, 54, 134, 190, 120, 135, 87, 136, 137, 138,
18, 19, 139, 18, 30, 94, 140, 190, 6, 56, 94, 123, 129, 139,
141, 14, 29, 75, 142, 153, 143, 189, 14, 16, 68, 83, 137, 144,
203, 41, 66, 145, 51, 146, 177, 147, 176, 148, 175, 149, 189,
193, 97, 130, 139, 141, 150, 10, 62, 76, 77, 122, 151, 175, 182,
206, 18, 101, 139, 152, 114, 115, 125, 153, 49, 154, 4, 20, 90,
155, 168, 184, 10, 76, 93, 156, 30, 157, 14, 96, 158, 20, 72,
98, 159, 190, 160, 120, 161, 62, 162, 51, 55, 116, 128, 163,
27, 46, 44, 76, 97, 141, 144, 165, 31, 76, 166, 3, 10, 111, 167,
105, 168, 184, 200, 169, 170, 70, 171, 77, 81, 93, 172, 109,
173, 198, 99, 174, 111, 148, 175, 183, 194, 176, 107, 135, 146,
177, 178, 179, 180, 28, 108, 181, 182, 10, 175, 180, 183, 194,
130, 184, 18, 185, 186, 2, 4, 159, 187, 68, 188, 201, 143, 189,
174, 190, 56, 166, 191, 80, 192, 76, 193, 3, 194, 68, 77, 196,
17, 77, 197, 21, 198, 199, 200, 201, 202, 136, 203, 204, 110,
139, 151, 206, 207, 28, 209, 36, 2, 4, 5, 6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, 23, 1, 1, 15, 1, 1, 1, 18, 1, 1, 1,
1, 2, 1, 1, 11, 1, 3, 2, 17, 1, 16, 1, 2, 1, 3, 1, 1, 5, 2, 1,
1, 11, 2, 11, 1, 20, 1, 12, 1, 8, 1, 1, 1, 1, 1, 6, 7, 1, 2,
1, 1, 1, 4, 1, 1, 4, 1, 1, 1, 18, 5, 3, 2, 9, 1, 12, 1, 1, 1,
7, 2, 2, 1, 1, 2, 7, 1, 14, 1, 1, 12, 1, 1, 1, 6, 1, 8, 2, 2,
2, 16, 1, 1, 1, 2, 10, 2, 1, 1, 1, 1, 1, 1, 10, 1, 1, 11, 1,
1, 4, 7, 1, 8, 1, 1, 14, 11, 3, 7, 1, 1, 1, 11, 1, 12, 1, 1,
11, 1, 3, 5, 1, 1, 4, 1, 1, 1, 7, 10, 12, 6, 1, 2, 6, 8, 2, 1,
1, 4, 1, 1, 6, 1, 8, 4, 1, 2, 1, 2, 1, 4, 1, 1, 2, 1, 3, 1, 1,
4, 1, 4, 2, 1, 3, 1, 2, 2, 5, 1, 2, 1, 1, 3, 5, 5, 4, 4, 1, 2,
1, 1, 1, 1, 1, 1, 1, 2), .Dim = c(1227L, 3L), .Dimnames = list(
NULL, c("a", "b", "c")))
Your variable b contains one NA. If you run the code after removing the NA, it works fine. You can use the following code
summary(netmat1_matrix)
#> a b c
#> Min. : 1.00 Min. : 1.00 Min. : 1.000
#> 1st Qu.: 23.00 1st Qu.: 44.00 1st Qu.: 1.000
#> Median : 62.00 Median : 95.50 Median : 1.000
#> Mean : 72.93 Mean : 97.18 Mean : 5.328
#> 3rd Qu.:114.00 3rd Qu.:144.00 3rd Qu.: 3.000
#> Max. :209.00 Max. :209.00 Max. :246.000
#> NA's :1
library(network)
df <- na.omit(netmat1_matrix) #Delete the row containing NA
summary(df)
#> a b c
#> Min. : 1.00 Min. : 1.00 Min. : 1.000
#> 1st Qu.: 23.00 1st Qu.: 44.00 1st Qu.: 1.000
#> Median : 62.00 Median : 95.50 Median : 1.000
#> Mean : 72.95 Mean : 97.18 Mean : 5.332
#> 3rd Qu.:114.00 3rd Qu.:144.00 3rd Qu.: 3.000
#> Max. :209.00 Max. :209.00 Max. :246.000
See the NA has been removed from variable b. Now run the network function without any error
network(df, matrix.type = "edgelist")
I have a network and I found the degree of the nodes.
I created two charts:
the first represents the network in such a way that the nodes of degree greater are larger and I used the RColorBrewer library for coloring the nodes
the second graph is a barplot which always represents the degree of each node.
I wish the same nodes have the same color.
For example, the Valjean node in the first graph is green/blue, while in the second is yellow.
How can I do so that it has the same color in both graphs?
This is the code:
library(igraph)
library(RColorBrewer)
library(sna)
library(scales)
library(plotrix)
net <- read.graph("./s.gml", format = c("gml"))
dput(net)
# find degree
deg <- igraph::degree(net, mode = "all")
pal <- rev(colorRampPalette(RColorBrewer::brewer.pal(9, "Set2"))(max(deg)))
##### FIRST CHART ######
labelSpecific <- ifelse(igraph::degree(net) > 35, V(net)$label, NA)
lab1 <- labelSpecific
V(net)$label.color <- "black"
x11()
V(net)$frame.color <- NA
plot(net,
vertex.color = pal[deg - min(deg) + 1],
vertex.size = plotrix::rescale(deg, c(4, 15)),
vertex.label = lab1,
main = "Degree")
###### SECOND CHART #########
mar.default <- c(5, 4, 4, 2) + 0.1
par(mar = mar.default + c(4, 0, 0, 0))
V(net)$label <- V(net)$label
x11()
barplot(height = deg,
space = 1,
names.arg = V(net)$label,
main = "Degree",
ylab = "Degree",
ylim = c(0, 40),
cex.axis = 1,
cex.names = 0.6,
col = pal,
border = NA,
las = 2)
I get this image.
My network is:
> dput(net)
structure(list(77, FALSE, c(1, 2, 3, 3, 4, 5, 6, 7, 8, 9, 11,
11, 11, 11, 12, 13, 14, 15, 17, 18, 18, 19, 19, 19, 20, 20, 20,
20, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23,
23, 23, 23, 23, 23, 24, 24, 25, 25, 25, 26, 26, 26, 26, 27, 27,
27, 27, 27, 28, 28, 29, 29, 29, 30, 31, 31, 31, 31, 32, 33, 33,
34, 34, 35, 35, 35, 36, 36, 36, 36, 37, 37, 37, 37, 37, 38, 38,
38, 38, 38, 38, 39, 40, 41, 41, 42, 42, 42, 43, 43, 43, 44, 44,
45, 47, 48, 48, 48, 48, 49, 49, 50, 50, 51, 51, 51, 52, 52, 53,
54, 54, 54, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 56, 56, 57,
57, 57, 58, 58, 58, 58, 58, 59, 59, 59, 59, 60, 60, 60, 61, 61,
61, 61, 61, 61, 62, 62, 62, 62, 62, 62, 62, 62, 63, 63, 63, 63,
63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65,
65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 66, 66, 66, 66, 66,
66, 67, 68, 68, 68, 68, 68, 68, 69, 69, 69, 69, 69, 69, 69, 70,
70, 70, 70, 70, 70, 70, 70, 71, 71, 71, 71, 71, 71, 71, 71, 72,
72, 72, 73, 74, 74, 75, 75, 75, 75, 75, 75, 75, 76, 76, 76, 76,
76, 76, 76), c(0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 10, 3, 2, 0, 11,
11, 11, 11, 16, 16, 17, 16, 17, 18, 16, 17, 18, 19, 16, 17, 18,
19, 20, 16, 17, 18, 19, 20, 21, 16, 17, 18, 19, 20, 21, 22, 12,
11, 23, 11, 24, 23, 11, 24, 11, 16, 25, 11, 23, 25, 24, 26, 11,
27, 23, 27, 11, 23, 30, 11, 23, 27, 11, 11, 27, 11, 29, 11, 34,
29, 34, 35, 11, 29, 34, 35, 36, 11, 29, 34, 35, 36, 37, 11, 29,
25, 25, 24, 25, 41, 25, 24, 11, 26, 27, 28, 11, 28, 46, 47, 25,
27, 11, 26, 11, 49, 24, 49, 26, 11, 51, 39, 51, 51, 49, 26, 51,
49, 39, 54, 26, 11, 16, 25, 41, 48, 49, 55, 55, 41, 48, 55, 48,
27, 57, 11, 58, 55, 48, 57, 48, 58, 59, 48, 58, 60, 59, 57, 55,
55, 58, 59, 48, 57, 41, 61, 60, 59, 48, 62, 57, 58, 61, 60, 55,
55, 62, 48, 63, 58, 61, 60, 59, 57, 11, 63, 64, 48, 62, 58, 61,
60, 59, 57, 55, 64, 58, 59, 62, 65, 48, 63, 61, 60, 57, 25, 11,
24, 27, 48, 41, 25, 68, 11, 24, 27, 48, 41, 25, 69, 68, 11, 24,
27, 41, 58, 27, 69, 68, 70, 11, 48, 41, 25, 26, 27, 11, 48, 48,
73, 69, 68, 25, 48, 41, 70, 71, 64, 65, 66, 63, 62, 48, 58),
c(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 13, 12, 11, 10, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 47, 46, 39, 40, 41, 42, 43, 44,
45, 49, 48, 52, 51, 50, 54, 55, 53, 56, 57, 58, 60, 59, 61,
62, 63, 66, 64, 65, 67, 69, 70, 71, 68, 72, 73, 74, 75, 76,
77, 79, 78, 82, 83, 80, 81, 87, 88, 84, 85, 86, 93, 94, 89,
90, 91, 92, 95, 96, 97, 98, 101, 100, 99, 102, 103, 104,
106, 105, 107, 108, 112, 110, 111, 109, 114, 113, 116, 115,
119, 118, 117, 121, 120, 122, 125, 124, 123, 131, 132, 133,
130, 128, 134, 135, 127, 126, 129, 136, 137, 139, 140, 138,
145, 143, 142, 141, 144, 148, 147, 149, 146, 150, 151, 152,
153, 158, 157, 154, 156, 155, 164, 162, 159, 163, 160, 161,
166, 165, 168, 174, 170, 171, 167, 173, 172, 169, 184, 177,
175, 183, 179, 182, 181, 180, 176, 178, 187, 194, 193, 189,
192, 191, 190, 188, 185, 186, 200, 196, 197, 203, 202, 198,
201, 195, 199, 204, 206, 207, 205, 208, 210, 209, 213, 214,
211, 215, 217, 216, 212, 221, 222, 218, 223, 224, 225, 220,
219, 230, 233, 226, 232, 231, 228, 227, 229, 236, 234, 235,
237, 238, 239, 242, 244, 243, 241, 240, 245, 246, 252, 253,
251, 250, 247, 248, 249), c(0, 1, 2, 4, 5, 6, 7, 8, 9, 13,
3, 12, 11, 10, 14, 15, 16, 17, 47, 49, 52, 54, 57, 62, 66,
69, 72, 73, 75, 77, 82, 87, 93, 102, 106, 112, 114, 119,
131, 145, 184, 206, 213, 221, 230, 236, 46, 18, 19, 21, 24,
28, 33, 39, 55, 132, 20, 22, 25, 29, 34, 40, 23, 26, 30,
35, 41, 27, 31, 36, 42, 32, 37, 43, 38, 44, 45, 48, 51, 58,
64, 67, 70, 50, 53, 60, 97, 101, 116, 207, 214, 222, 56,
59, 95, 96, 98, 100, 110, 133, 205, 211, 218, 233, 242, 61,
103, 113, 118, 125, 130, 234, 63, 65, 71, 74, 104, 111, 143,
208, 215, 223, 226, 235, 105, 107, 76, 79, 83, 88, 94, 68,
78, 80, 84, 89, 81, 85, 90, 86, 91, 92, 121, 128, 99, 134,
139, 164, 210, 217, 224, 232, 244, 108, 109, 135, 140, 142,
148, 150, 153, 162, 168, 177, 187, 200, 209, 216, 231, 237,
238, 243, 252, 115, 117, 124, 127, 136, 120, 122, 123, 126,
129, 137, 138, 141, 147, 158, 159, 174, 175, 194, 144, 149,
157, 163, 170, 183, 193, 204, 146, 151, 154, 160, 171, 179,
189, 196, 225, 253, 152, 156, 161, 167, 182, 192, 197, 155,
166, 173, 181, 191, 203, 165, 172, 180, 190, 202, 169, 176,
188, 198, 251, 178, 185, 201, 250, 186, 195, 247, 199, 248,
249, 212, 220, 228, 241, 219, 227, 240, 229, 245, 246, 239
), c(0, 0, 1, 2, 4, 5, 6, 7, 8, 9, 10, 10, 14, 15, 16, 17,
18, 18, 19, 21, 24, 28, 33, 39, 48, 50, 53, 57, 62, 64, 67,
68, 72, 73, 75, 77, 80, 84, 89, 95, 96, 97, 99, 102, 105,
107, 108, 108, 109, 113, 115, 117, 120, 122, 123, 126, 136,
138, 141, 146, 150, 153, 159, 167, 175, 185, 195, 204, 205,
211, 218, 226, 234, 237, 238, 240, 247, 254), c(0, 10, 10,
12, 13, 13, 13, 13, 13, 13, 13, 14, 46, 47, 47, 47, 47, 56,
62, 67, 71, 74, 76, 77, 83, 92, 105, 112, 124, 126, 131,
132, 132, 132, 132, 136, 139, 141, 142, 142, 144, 144, 153,
153, 153, 153, 153, 154, 155, 173, 178, 178, 182, 182, 182,
183, 192, 192, 200, 210, 217, 223, 228, 233, 237, 240, 242,
243, 243, 247, 250, 252, 253, 253, 254, 254, 254, 254), list(
c(1, 0, 1), structure(list(), .Names = character(0)),
structure(list(id = c(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
67, 68, 69, 70, 71, 72, 73, 74, 75, 76), label = c("Myriel",
"Napoleon", "MlleBaptistine", "MmeMagloire", "CountessDeLo",
"Geborand", "Champtercier", "Cravatte", "Count", "OldMan",
"Labarre", "Valjean", "Marguerite", "MmeDeR", "Isabeau",
"Gervais", "Tholomyes", "Listolier", "Fameuil", "Blacheville",
"Favourite", "Dahlia", "Zephine", "Fantine", "MmeThenardier",
"Thenardier", "Cosette", "Javert", "Fauchelevent", "Bamatabois",
"Perpetue", "Simplice", "Scaufflaire", "Woman1", "Judge",
"Champmathieu", "Brevet", "Chenildieu", "Cochepaille",
"Pontmercy", "Boulatruelle", "Eponine", "Anzelma", "Woman2",
"MotherInnocent", "Gribier", "Jondrette", "MmeBurgon",
"Gavroche", "Gillenormand", "Magnon", "MlleGillenormand",
"MmePontmercy", "MlleVaubois", "LtGillenormand", "Marius",
"BaronessT", "Mabeuf", "Enjolras", "Combeferre", "Prouvaire",
"Feuilly", "Courfeyrac", "Bahorel", "Bossuet", "Joly",
"Grantaire", "MotherPlutarch", "Gueulemer", "Babet",
"Claquesous", "Montparnasse", "Toussaint", "Child1",
"Child2", "Brujon", "MmeHucheloup"), maincharacter = c(0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0)), .Names = c("id", "label", "maincharacter"
)), structure(list(value = c(1, 8, 10, 6, 1, 1, 1, 1,
2, 1, 1, 3, 3, 5, 1, 1, 1, 1, 4, 4, 4, 4, 4, 4, 3, 3,
3, 4, 3, 3, 3, 3, 5, 3, 3, 3, 3, 4, 4, 3, 3, 3, 3, 4,
4, 4, 2, 9, 2, 7, 13, 1, 12, 4, 31, 1, 1, 17, 5, 5, 1,
1, 8, 1, 1, 1, 2, 1, 2, 3, 2, 1, 1, 2, 1, 3, 2, 3, 3,
2, 2, 2, 2, 1, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 1, 1, 1,
2, 3, 2, 2, 1, 3, 1, 1, 3, 1, 2, 1, 2, 1, 1, 1, 3, 2,
1, 1, 9, 2, 2, 1, 1, 1, 2, 1, 1, 6, 12, 1, 1, 21, 19,
1, 2, 5, 4, 1, 1, 1, 1, 1, 7, 7, 6, 1, 4, 15, 5, 6, 2,
1, 4, 2, 2, 6, 2, 5, 1, 1, 9, 17, 13, 7, 2, 1, 6, 3,
5, 5, 6, 2, 4, 3, 2, 1, 5, 12, 5, 4, 10, 6, 2, 9, 1,
1, 5, 7, 3, 5, 5, 5, 2, 5, 1, 2, 3, 3, 1, 2, 2, 1, 1,
1, 1, 3, 5, 1, 1, 1, 1, 1, 6, 6, 1, 1, 2, 1, 1, 4, 4,
4, 1, 1, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, 2, 1, 1, 2,
2, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)), .Names = "value")),
<environment>), class = "igraph")
You are passing two different colors vectors to plot and to barplot.
Just use the same code for both, e.g. in the barplot use:
barplot(
...
col = pal[deg - min(deg) + 1]
...
)