Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 204771

using textInput to define url to scrape from

$
0
0

My goal is an app that scrapes and maps html table data, by date. Each date has its own url with its yyyymmdd suffix, eg:

https://cdec.water.ca.gov/reportapp/javareports?name=PAGE6.20191219https://cdec.water.ca.gov/reportapp/javareports?name=PAGE6.20191216

The intention is for the user to enter the 8-digit date in a textInput field, and the app to build the url and scrape and map the data.

With what I have:

library(shiny)
library(leaflet)
library(shinyjs)
library(shinydashboard)
library(XML)

ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(

textInput("text", "by 8 digit yyyymmdd:", "20191216")),

dashboardBody(
tags$style(type = "text/css", "#mapplot {height: calc(100vh - 80px) !important;}"),
leafletOutput("mapplot"),
useShinyjs() ) )

server <- function(input, output) {
 addClass(selector = "body")
 options(shiny.maxRequestSize=225*1024^2)

baseurl <- "http://cdec.water.ca.gov/reportapp/javareports?name=PAGE6."

# append the user-entered yyyymmdd to the base url
url <- reactive({paste0(baseurl, input$text)})

# scrape data
cdec_swe_table  <- readHTMLTable(url)

# process data and display on map
# this part already works, it's defining the url from user input that I can't do

}

shinyApp(ui, server)

I get:

Error in (function (classes, fdef, mtable)  : 
unable to find an inherited method for function ‘readHTMLTable’ for 
signature ‘"reactiveExpr"’

I think I'm missing some reactivity fundamentals. Any help greatly appreciated.


Viewing all articles
Browse latest Browse all 204771

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>