I am trying to build a financial dashboard in shiny and am stuck on the first step. I want to write a piece that reads in the following table
The code looks like this:
library(rvest)
library(dplyr)
url <- ("https://stockanalysis.com/stocks/")
page <- read_html(url)
stocks <- page %>%
html_nodes('table#symbol-table') %>%
html_table() %>% .[[1]]
And the whole Shiny App will look like this:
library(shiny)
library(rvest)
library(dplyr)
url <- ("https://stockanalysis.com/stocks/")
page <- read_html(url)
page
stocks <- page %>%
html_nodes('table#symbol-table') %>%
html_table() %>% .[[1]]
ui <- fluidPage(
sliderInput(inputId = "num",
label = "Choose a number",
value = 25, min = 1, max = 100),
dataTableOutput("T")
)
server <- function(input, output) {
output$T <- renderDataTable({
stocks
})
}
shinyApp(ui = ui, server = server)