当我像这样在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()
})
})
我的输出如下:
我想要这个:
我不知道问题出在哪里,因为应该根据我的数据集定义数字变量。但是以某种方式,我的变量减少到了y轴上的一点。