Please help in reading data into R shiny app

library(shiny)
library(DT)
rate <- read_csv("FITB.csv")
# Define UI 
ui <- fluidPage(
  
   # Appl title
   titlePanel("Fifth Third Stock price"),
   
   # Sidebar with a slider input for number of bins 
  #  dateRangeInput('dateRange',
  #                 label = 'Date range input: yyyy-mm-dd',
  #                 start = 2018-11-12, end = 2019-11-12, min = 2018-11-12, max = 2019-11-12, weekstart = 1
  #  )
  # )
sidebarLayout(
  sidebarPanel(dateRangeInput("date_range", label=h3("Date Range"),start="2018-11-12", end="2019-11-12")
  ),
  selectInput("variable", "What do you want to see:",
              choices = c("Open", "High", "Low", "Volume")), 
  actionButton("update", "Update table"),
  mainPanel(
    tableOutput("table")
  )
))


# Define server
server <- function(input, output) {
   
   #output$distPlot <- renderPlot({
      # generate dates and table
     output$dateRangeText  <- renderText({
       paste("input$dateRange is", 
             paste(as.character(input$dateRange), collapse = " to "))})
       output$datatable <- renderDT(rate, class = "display nowrap compact", # style
                                    filter = "top") # location of column filters
     
       
      
     }
      


# Run the application 
shinyApp(ui = ui, server = server)

I want to have a side panel for date range mentioned above. This is the link to the data table I want Shiny to display when a certain date range is selected. https://finance.yahoo.com/quote/FITB/history/

read_csv requires library(readr). Your ui brackets were also mistmatched. Your input ids "xxx" need to match what you call with input$xxx. And looks like you need to use DTOutput.


library(shiny)
library(DT)
library(readr)

rate <- read_csv("FITB.csv")

# Define UI
ui <- fluidPage(

  # Appl title
  titlePanel("Fifth Third Stock price"),

  # Sidebar with a slider input for number of bins
  #  dateRangeInput('dateRange',
  #                 label = 'Date range input: yyyy-mm-dd',
  #                 start = 2018-11-12, end = 2019-11-12, min = 2018-11-12, max = 2019-11-12, weekstart = 1
  #  )
  # )
  sidebarLayout(
    sidebarPanel(
      dateRangeInput("dateRange", label = h3("Date Range"), start = "2018-11-12", end = "2019-11-12"),
      selectInput("variable", "What do you want to see:", choices = c("Open", "High", "Low", "Volume")),
      actionButton("update", "Update table")
    ),
    mainPanel(
      DTOutput("table")
    )
  )

)

# Define server
server <- function(input, output) {

  # output$distPlot <- renderPlot({
  # generate dates and table
  output$dateRangeText <- renderText({
    paste(
      "input$dateRange is",
      paste(as.character(input$dateRange), collapse = " to ")  # name must match the input
    )
  })

  output$table <- renderDT({
	  	rate 
	  },
	  class = "display nowrap compact", filter = "top"
  ) # location of column filters

}

# Run the application
shinyApp(ui = ui, server = server)

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.