I have a very basic Shiny app that looks something like this:
library(shiny)
library(tidyverse)
dataframe1 <- data.frame(Player = rep(c("Lebron", "Steph", "Harden",
"Giannis"), each = 30),
Game = rep(1:30, 4),
Points = round(runif(120, 15, 40), 0))
ui <- fluidPage(
sidebarPanel(
selectInput("player",
"Select a player",
choices = unique(dataframe1$Player))
),
mainPanel(
tableOutput("average"),
plotOutput("ptdist")
)
)
server <- function(input, output){
playerFilt <- reactive({
dataframe1 %>%
filter(Player == input$player)
})
output$average <- renderTable({
playerFilt() %>%
summarise(PPG = sum(Points) / n())
})
output$ptdist <- renderPlot({
playerFilt() %>%
ggplot() +
geom_histogram(aes(x = Points),binwidth = 2.5, fill = "skyblue", color = "black") +
theme_bw()
})
}
shinyApp(ui, server)
What I wanted to do, however, was hide this plot, and only show it in a pop up window, when someone clicked on the PPG value. Something like this, but making the value on the table clickable instead of creating an actionButton. I saw
Bárbara Borges' rstudio::conf() talk where she did something very close to what I'm looking for, but she took values from an entire row and it generated a text instead of a plot.
Is this possible? Can anyone help?
Thanks in advance!