闪亮的应用程序不渲染gvisGeoChart

时间:2018-04-13 20:30:43

标签: r shiny googlevis

我正在尝试使用googlevis创建我的第一个闪亮的应用程序,输出不是渲染地图,也没有给出任何错误。它渲染侧面板和选择输入面板,但不渲染地图输出。你能帮我解决一下这里出了什么问题吗?

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
                 ))  
  })

})

感谢您的意见。

1 个答案:

答案 0 :(得分:0)

您可以通过添加以下代码在本地运行该应用:

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