Tengo una consulta básica para alguien con conocimiento de Shiny apps. Mi aplicación posee el siguiente código, como se puede ver agregué un abline (linea roja) para deslizar con el slider por el gráfico creado. Resulta que no logro que cambiando el valor en el slider se cambie la posición de la línea roja en el gráfico. Me parece que no estoy relacionando bien la parte de ui y server de este ítem. ¿Alguien que pueda ayudarme por favor?
library(shiny)
# Define UI for application that draws a histogram
ui <- fluidPage(
# Application title
titlePanel("prueba01 data"),
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
sliderInput("bins",
"Number of bins:",
min = 1,
max = 50,
value = 30),
sliderInput("line", "Red line:",
min = 0, max = max(faithful$waiting),
value = 71),
),
# Show a plot of the generated distribution
mainPanel(
plotOutput("distPlot")
)
)
)
# Define server logic required to draw a histogram
server <- function(input, output) {
output$distPlot <- renderPlot({
# generate bins based on input$bins from ui.R
x <- faithful[, 2]
bins <- seq(min(x), max(x), length.out = input$bins + 1)
line <- seq(min(x), max(x), length.out = input$line + 1)
# draw the histogram with the specified number of bins
hist(x, breaks = bins, col = 'darkgray', border = 'white', abline = mean,
xlab = 'Waiting time until next eruption (minutes)',
ylab = 'Frecuency',
main = 'Waiting time hist')
abline(v= 71,col="red")
})
}
# Run the application
shinyApp(ui = ui, server = server)