【发布时间】:2020-09-12 08:38:49
【问题描述】:
为了研究,我正在研究雷达图的可视化。由于我的研究中有各种主题要包含,我希望有一个使用 Shiny 的反应式雷达图,其中“读者”可以从几行值中选择他们想要在雷达图中看到的内容。但是,我无法做到这一点。
我的数据框如下所示:
Power Alliances National Interest
max 40 40 40
min 0 0 0
lib 4 6 30
left 1 15 10
因为我希望能够在 lib 和 left 之间选择作为我的反应式闪亮雷达图中的变量,并让雷达图本身由 权力、联盟和国家利益,我创建了以下代码:
ui <- shinyUI(fluidPage(
# Application title
titlePanel("Political Parties"),
sidebarPanel(
selectInput(
inputId = "left_lib",
label = "Argument_Type",
choices = list("New_Left_Green"="left", "Liberal"="lib")
)
),
fluidRow(column(12,plotOutput("radarPlot"))
)))
server <- shinyServer(function(input, output) {
output$radarPlot <- renderPlot({
req(input$left_lib)
radarchart(input$left_lib,
seg=6,
title = "New Left / Green versus Liberal in The Netherlands",
pcol=colors_line,
plwd=2)
legend(x=1.6,
y=1.35,
legend = rownames(left_lib[-c(1,2),]),
bty = "n", pch=20, col=colors_line, cex=1.2, pt.cex = 3)
})})
shinyApp(ui = ui, server = server)
雷达图已创建,但它不会对在侧面板中选择 lib 或 left 做出反应。我该如何解决这个问题?
提前谢谢你。
【问题讨论】:
标签: plot graph server shiny radar-chart