将ggplot2与Rshiny一起使用:ggplot y轴上显示的电平不正确

时间:2018-11-02 15:22:16

标签: r ggplot2 shiny

当我像这样在RShiny中使用ggplot2时:

# Define UI for miles per gallon application
shinyUI(pageWithSidebar(

  # Application title
  headerPanel("Healthcare"),

  # Sidebar with controls to select the variable to plot against mpg
  # and to specify whether outliers should be included
  sidebarPanel(
    selectInput("variable", "Factor: ",
                list("Uninsured %" = "uninsured", 
                     "Primary Care Physicians" = "primary_care_physicians", 
                     "Mental Health Providers" = "mental_health_providers",
                     "Dentists" = "dentists"
                     ))
  ),

  mainPanel(
    plotOutput("yearPlot"))
))

shinyServer(function(input, output) {

      output$yearPlot <- renderPlot({
        ggplot(insurance, aes(year, input$variable, color = County)) + geom_point() + geom_line() 
      })

    })

我的输出如下:

enter image description here

我想要这个:

enter image description here

我不知道问题出在哪里,因为应该根据我的数据集定义数字变量。但是以某种方式,我的变量减少到了y轴上的一点。

0 个答案:

没有答案