如何在 Shiny 中创建雷达图?

How to create a radar chart in Shiny?

我今晚有一项任务要完成,我必须创建最后一个绘图:Shiny 中的雷达图。

尽管使用此代码创建了“正常”雷达图,但我还是无法弄清楚:

mvr <- fifa %>%

filter (year == 2021) %>%
  filter (short_name %in% c("L. Messi", "Cristiano Ronaldo")) %>%
  select (-"short_name", -"age", -"height_cm", -"weight_kg", -"nationality", -"club_name", -"league_rank", -"overall", -"potential", -"value_eur", -"wage_eur", -"preferred_foot", -"team_position", -"year", -"Position")

maxmin <- data.frame( Attack = c(99,0), Skill = c(99,0), Movement = c(99,0), Power = c(99,0), Mentality = c(99,0), Defense = c(99,0), Goalkeeping = c(99,0) )

rownames(maxmin) <- c("Max", "Min")

comparison <- bind_rows(maxmin, mvr)

radarchart(comparison)

我的数据库是“fifa”,由多行球员和球员表现属性、年份、俱乐部名称等列组成。我只想每次 select 两名球员并使用比较他们的表现属性雷达图。

我想为我的 Shiny 仪表板重新创建上面的代码。 有人有想法吗?

我写了这个:

  output$radar <- renderPlotly({
mvr <- filter(fifa, name == input$short_name) %>%
  select (-"short_name", -"age", -"height_cm", -"weight_kg", -"nationality", -"club_name", -"league_rank", -"overall", -"potential", -"value_eur", -"wage_eur", -"preferred_foot", -"team_position", -"year", -"Position")

maxmin <- data.frame( Attack = c(99,0), Skill = c(99,0), Movement = c(99,0), Power = c(99,0), Mentality = c(99,0), Defense = c(99,0), Goalkeeping = c(99,0) )
rownames(maxmin) <- c("Max", "Min")
comparison <- bind_rows(maxmin, mvr)

fig <- plot_ly(comparison)})

但是没用。

在 Rstudio Shiny Gallery 上试用此应用程序

https://shiny.rstudio.com/gallery/soccer-player-similarity.html