I'm afraid I need more help debugging my shiny code.
I added browser() to a renderUI statement as someone suggested. That works fine when I create my base.list() from lists. However, it doesn't work when I create base.list() from an uploaded file. I need to work with updated files like the one I copied below the following R code.
Thanks for any help you can give me on this.
library(tidyverse)
library(shiny)
library(lubridate)
library(ggplot2)
ui <- fluidPage(
titlePanel("What if? Trend"),
sidebarLayout(
sidebarPanel(
fileInput("upload.file", "Upload trend data file",
multiple = FALSE,
accept = ".csv"),
uiOutput("base.date.output"),
uiOutput("launch.date.output"),
),
mainPanel(
)
)
)
server <- function(input, output, session) {
# upload trend data file ----
t.input <- eventReactive(input$upload.file, {
read_csv(input$upload.file$datapath)
})
#----
# create base.list from uploaded trend data file ---
base.list <-reactive(
{
req(t.input())
as.list(t.input()[,1])
}
)
#----
# # create base.list from lists ----
# list1 <- list(1900,1910,1920,1930,
# 1940,1950,1960,1970
# ,1980,1990,2000,2010)
# list1 <- as.data.frame(list1)
# list1 <- t(list1)
# list2 <- list(21.112,27.881,44.051,70.278,
# 86.942,136.395,256.782,415.387,
# 483.024,545.837,665.865,691.893)
# list2 <- as.data.frame(list2)
# list2 <- t(list2)
# t.input <- reactive(cbind(list1,list2))
#
# base.list <-reactive(
# {
# req(t.input())
# setNames( as.list(t.input()[,1]),
# NULL)
# }
# )
# #----
launch.list <- reactive(
base.list()
)
# Specify parameters ----
output$base.date.output <- renderUI({
browser()
selectInput("base.date",
label = "Select base date",
choices = base.list(),
selected = "")
})
output$launch.date.output <- renderUI({
selectInput("launch.date",
label = "Select launch date",
choices = launch.list(),
selected = "")
})
}
shinyApp(ui, server)
date | popln |
---|---|
1900 | 21.112 |
1910 | 27.881 |
1920 | 44.051 |
1930 | 70.278 |
1940 | 86.942 |
1950 | 136.395 |
1960 | 256.782 |
1970 | 415.387 |
1980 | 483.024 |
1990 | 545.837 |
2000 | 665.865 |
2010 | 691.893 |