1
我試圖創建一個閃亮的應用程序,允許我過濾聯賽數據。這是該數據集的例子:鏈接閃亮的選擇參數
list <- c(2.3, 2.5, 2.6, 2.8, 4.12, 5.3, 6.2, 8.2)
team <- c("A", "A", "A", "A", "B", "B", "B", "B")
time <- c(1,2,3,4,5,6,7,8)
league <- c("A", "B","A", "B","A", "B","A", "B")
df <- data.frame(list, team, time, league)
林現在使用下面的腳本繪製數據:
#ui script
shinyUI(fluidPage(
titlePanel("Basic widgets"),
fluidRow(
column(3,
h3("Buttons"),
selectInput("select", label = h3("Select box"),
choices = list("Choice 1" = 1, "Choice 2" = 2), selected = 1)),
mainPanel(
plotOutput("distPlot")
)
)
))
而且服務器腳本:
library(shiny)
shinyServer(function(input, output) {
output$distPlot <- renderPlot({
list <- c(2.3, 2.5, 2.6, 2.8, 4.12, 5.3, 6.2, 8.2)
team <- c("A", "A", "A", "A", "B", "B", "B", "B")
time <- c(1,2,3,4,5,6,7,8)
league <- c("A", "B","A", "B","A", "B","A", "B")
df <- data.frame(list, team, time, league)
ggplot(df, aes(x = time, y = list, colour = team)) + geom_line()
})
})
這表明我的線兩個聯賽。但是我想實現的是我可以選擇「Choice1」和「Choice2」,並在圖中顯示相關的數據點。任何建議如何將選擇選項與獨特的聯盟價值聯繫起來?