Streamgraph, показывающий отсутствие вывода - PullRequest
0 голосов
/ 08 февраля 2020
library(streamgraph)

df:

    str
# A tibble: 20 x 3
# Groups:   gname [7]
   gname                                            iyear total
   <chr>                                            <int> <int>
 1 Islamic State of Iraq and the Levant (ISIL)       2016  1454
 2 Islamic State of Iraq and the Levant (ISIL)       2017  1315
 3 Islamic State of Iraq and the Levant (ISIL)       2014  1249
 4 Taliban                                           2015  1249
 5 Islamic State of Iraq and the Levant (ISIL)       2015  1221
 6 Taliban                                           2016  1065
 7 Taliban                                           2014  1035
 8 Taliban                                           2017   894
 9 Al-Shabaab                                        2014   871
10 Taliban                                           2012   800
11 Taliban                                           2013   775
12 Al-Shabaab                                        2017   570
13 Al-Shabaab                                        2016   564
14 Boko Haram                                        2015   540
15 Shining Path (SL)                                 1989   509
16 Communist Party of India - Maoist (CPI-Maoist)    2010   505
17 Shining Path (SL)                                 1984   502
18 Boko Haram                                        2014   495
19 Shining Path (SL)                                 1983   493
20 Farabundo Marti National Liberation Front (FMLN)  1991   492

Код для функции потокового графа:

streamgraph(data = str,key = "gname",date = "iyear", value = "total") %>%
  sg_annotate(label="ISIL", x=as.Date("2016-01-01"), y=1454, size=14)

К сожалению, он не показывает никакого вывода. Вы знаете, как решить эту проблему?

1 Ответ

1 голос
/ 08 февраля 2020

Это временный ответ для вас, если вы сказали, что хотите увидеть, что я на самом деле создаю график c. Сравните это с вашим собственным кодом. Я рад удалить этот ответ, как только вы закончите sh сравнение.

df <- data.frame(gname = c("Islamic State of Iraq and the Levant (ISIL)",
                           "Islamic State of Iraq and the Levant (ISIL)",
                           "Islamic State of Iraq and the Levant (ISIL)",
                           "Taliban",
                           "Islamic State of Iraq and the Levant (ISIL)",
                           "Taliban",
                           "Taliban",
                           "Taliban",
                           "Al-Shabaab",
                           "Taliban",
                           "Taliban",
                           "Al-Shabaab",
                           "Al-Shabaab",
                           "Boko Haram",
                           "Shining Path (SL)",
                           "Communist Party of India - Maoist (CPI-Maoist)",
                           "Shining Path (SL)",
                           "Boko Haram",
                           "Shining Path (SL)",
                           "Farabundo Marti National Liberation Front (FMLN)"),
                 iyear = c(2016, 2017, 2014, 2015, 2015, 2016, 2014,
                           2017, 2014, 2012, 2013, 2017, 2016, 2015, 1989, 2010,
                           1984, 2014, 1983, 1991),
                 total = c(1454, 1315, 1249, 1249, 1221, 1065,
                           1035, 894, 871, 800, 775, 570,
                           564, 540, 509, 505, 502, 495,
                           493, 492),
                 stringsAsFactors = F)


streamgraph(data = df ,key = "gname", date = "iyear", value = "total") %>%
sg_annotate(label = "ISIL", x = as.Date("2016-01-01"), y = 1454, size = 14)

enter image description here

...