【问题标题】:Shiny app not rendering gvisGeoChart闪亮的应用程序不呈现 gvisGeoChart
【发布时间】:2018-09-24 06:26:23
【问题描述】:

我正在尝试使用 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")
    )
  )
)

服务器.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
                 ))  
  })
  
})

感谢您的意见。

【问题讨论】:

    标签: r shiny googlevis


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 2015-09-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-15
      • 1970-01-01
      • 2021-08-13
      • 1970-01-01
      • 2020-02-22
      相关资源
      最近更新 更多