我正在创建一个Shiny应用程序,其中一个复选框组将过滤数据。我有以下文件:
ui.R
library(shiny)
shinyUI(fluidPage(
tags$head(
tags$style(HTML("
.multicol {
-webkit-column-count: 3; /* Chrome, Safari, Opera */
-moz-column-count: 3; /* Firefox */
column-count: 3;
}
"))
),
titlePanel(h1('NBA MVPs', align = "center")),
hr(),
mainPanel(
tabsetPanel(type='tabs',
tabPanel("Plot", plotOutput("plot")),
tabPanel("Description",
p('Blah blah blah')))),
hr(),
fluidRow(
column(2,
radioButtons('stat', "Statistics", choices=c('Field Goal %'='FG.Perc', '3 Pt. %'='ThreePointPerc',"Free Throw %" = "FTPerc", "Rebounds" = "TRB", "Assists" ="ASST", 'Steals' = "STL", "Points" = "PTS", "True Shooting %"= "TrueShootingPerc", "Eff. FG %"= "eFG", "Total Reb. %" = "TRBPerc", "Off. Rating" = "ORtg", "Def. Rating" = "DRtg")))
),
wellPanel(
tags$div(class = "multicol", checkboxGroupInput("player", choices = c("Player1" = '1', "Player2" = '2'), selected = c('1', '2')
))
)
))
server.R
library(shiny); library(dplyr); library(ggvis); library(mosaic)
data= PlayerData
shinyServer(function(input, output){
plotData <- reactive({
df <- data %>%
filter(player %in% input$player)
})
output$plot <- renderPlot(xyplot(FG~Rk, group=player, data=plotData(), auto.key=list(space='top', columns=2, lines=TRUE, points=FALSE, panel=function(x,y){
panel.xyplot(x,y)
panel.abline(h=0, col='red')
}))
)
})
当我使用上面的代码运行应用程序时,界面显示正常,但是没有出现情节,我收到错误:&#34;未使用的参数(by = _vars
)&#34;。但是,如果我删除了过滤服务器文件中数据的行,则会显示没有错误的图表。该数据包含一个名为&#39; player&#39;的列。包含&#39; 1&#39;或&#39; 2&#39;。
我不确定为什么这个过滤行会导致错误,但我不熟悉用于获取复选框的多个列的CSS,因此我怀疑这可能会导致问题。