我正在尝试制作这个闪亮的应用程序,我想在其中显示该州所有 NFL 球员每个赛季的平均传球码数。
football <- read_csv("Football.csv")
inputPanel(
selectInput(inputId = "var",
label = "Variable",
choices = c("Passes Attempted" = "Passes Attempted",
"Passes Completed" = "Passes Completed",
"Completion Percentage" = "Completion Percentage",
"Pass Attempts Per Game" = "Pass Attempts Per Game",
"TD Passes" = "TD Passes"),
selected = "Completion Percentage")
)
renderPlot({
Data1 = football%>%
filter(`Passing Yards` > 100)%>%
separate(`Birth Place`, into = c("Birth City","state"),sep = ", ",na.rm = TRUE) %>%
group_by(state) %>%
summarise(Avg = mean(input$var))
Data1 = Data1[complete.cases(Data1), ]
plot_usmap(data = Data1, values = "Avg", color = "white") +
scale_fill_viridis_c(option = "A",
name = "Average Passing Yards Per Season", label = scales::comma
) + theme(legend.position = "right")
})
但是当我尝试这样做时,它不起作用并给我一个错误说,
Warning in mean.default(input$var) :
argument is not numeric or logical: returning NA