0
votes

I am trying to create my first shiny app using googlevis, the output is not rendering map and doesn't give any errors too. It renders the sidepanel and selection input panels but not the map output. Could you please help me what went wrong here?

UI.R

    library(shiny)


# Define UI for application that draws a histogram
ui <- fluidPage(
  
  # Application title
  titlePanel("Cropped Acreage"),
  
  # Sidebar with a slider input  and select input 
  sidebarLayout(
    sidebarPanel(
      
      selectInput("CropInput",
                  label = "Select a crop to display",
                  choices = c("Corn", "Soybeans", "Wheat"),
                  selected = "Corn"
                  ),
      
      
      
      
      sliderInput("sliderYear",
                  "Select Year:",
                  min = 2011,
                  max = 2017,
                  value = 2014)
    ),
    
    # Show a plot of the generated distribution
    mainPanel(
      htmlOutput("plot1")
    )
  )
)

Server.R

library(shiny)
library(dplyr)
library(stringr)
library(googleVis)

nass_df <- read.csv('https://pastebin.com/raw/ndRBUsKK')
nass_df$state_name <- str_to_title(nass_df$state_name)
nass_df <- subset(nass_df, state_name != "Other States" & year > 2011)


shinyServer(function(input, output) {
  datasetInput <- reactive({
    datasetInputFilter <- nass_df %>% 
      filter(., commodity_desc == input$CropInput & year == input$sliderYear )
  })
  
  output$plot1 <- renderGvis({
    gvisGeoChart(datasetInput() ,
                 "state_name",
                 "Value_ha",
                 options = list(
                   region = "US",
                   displayMode = "regions",
                   resolution = "provinces",
                   width = 800,
                   height = 600
                 ))  
  })
  
})

Appreciate your input.

1

1 Answers

0
votes

You can run the app locally by adding the code below:

library(googleVis)
library(shiny)
runGist(4970975)