I want to create a scatterplot using R-Shiny App. I need 2 input (selectInput and checkboxGroupInput) to display my plot. When I run the code, it show this error :
Error: (converted from warning) Error in : (converted from warning) Error in max: (converted from warning) no non-missing arguments to max; returning -Inf
It seems that selectInput is OK but not checkboxGroupInput, because when I try to filter data with 2 selectInput, it works... See my code :
ui = fluidPage(
headerPanel('Title'),
sidebarPanel(
selectInput(inputId = 'adv', label = 'Adversaire', choices = levels(nodes$Adversaire)),
checkboxGroupInput(inputId = 'act', label = 'Actions', choices = levels(nodes$Action))
),
mainPanel(plotOutput('scatter'))
)
server <- function(input, output) {
data = reactive({
df = nodes %>%
filter(Adversaire == input$adv, Action %in% c(input$act)) %>%
group_by(Player) %>%
summarise(Poste = unique(Poste),
Pour_brut = sum(Pour), Contre_brut = sum(Contre), Total_brut = sum(Total),
Pour = sum(Pour_brut)/mean(unique(Time))*20, Contre = sum(Contre_brut)/mean(unique(Time))*20, Total = sum(Total)/mean(unique(Time))*20,
Time = mean(unique(Time)))
})
output$scatter = renderPlot({
ggplot(data(), aes(x = Contre, y = Pour, color = Poste, size = Time)) +
scale_x_continuous(limits = c(0,max(c(data()$Contre, data()$Pour)))) +
scale_y_continuous(limits = c(0,max(c(data()$Contre, data()$Pour)))) +
geom_abline(intercept = 0, slope=1) +
geom_point()
})
}
shinyApp(ui = ui, server = server)
Aucun commentaire:
Enregistrer un commentaire