在R的高图内循环

时间:2019-05-08 09:20:30

标签: r loops highcharts rstudio shinydashboard

我必须在RStudio上自动化对数据集的分析。

我的问题是我不知道数据集中将有多少个序列。所以我想知道是否可以在Highcharts内进行for循环?

我不知道它是否行不通,因为我做错了事或因为不可能。

output$hc2 <- renderHighchart ({
Hchc <- highchart(hcaes(x = Spring ,y = Ponctuation)) %>% 
  hc_title(text = "Cumulation of the result of a Team per spring",
           margin = 20, align = "left",
           style = list(color = "#FE8000", useHTML = TRUE)) %>% 
  hc_xAxis(categories = tableA$Spring, title = list(text = "Number of spring",color = "#FE8000")) %>%
  hc_yAxis(title = list(text = "Cumulation of the result", color = "#FE8000"))%>% 

  for (i in length(mylist)){
    hc_add_series(name = name[i], data = mylistcumu[[i]]$CumuPonct) }

print(Hchc)})

1 个答案:

答案 0 :(得分:1)

我发现了!

output$hc2 <- renderHighchart ({
Hchc <- highchart(hcaes(x = Spring ,y = Ponctuation)) %>% 
hc_title(text = "Cumulation of the result of a Team per spring",
           margin = 20, align = "left",
           style = list(color = "#FE8000", useHTML = TRUE)) %>% 
hc_xAxis(categories = tableA$Spring, title = list(text = "Number of spring",color = "#FE8000")) %>%
hc_yAxis(title = list(text = "Cumulation of the result", color = "#FE8000"))

for (i in 1:length(mylist)){
  Hchc <- Hchc %>%
   hc_add_series(name = name[i], data = mylistcumu[[i]]$CumuPonct) }

Hchc})