r - 将 ggplot2 与 Rshiny 一起使用:ggplot y 轴上显示的级别不正确
问题描述
当我像这样在 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 轴的图表上减少到只有一个点。
解决方案
推荐阅读
- php - Laravel 7 - 刀片 IF
- ios - [NSProgress cancel]_block_invoke 崩溃,可能在 AFNetworking
- javascript - 来自获取 URL 的数据并在另一个函数中使用该数据(关于范围的问题)
- reactjs - ant.d - 表单 - 如何使用标准规则 API 显示警告?
- flutter - 输入'列表
'不是'String'类型的子类型颤动错误 - bash - 如何将ffmpeg的输出转换成python?
- python-3.x - BrowserMobProxy: ConnectionRefusedError: [WinError 10061] 系统重启后
- mongodb - Mongodb:替换或添加多语言文本
- tensorflow - Bodypix:将 wasm 用于 SIMD + 多线程
- html - 如何创建一个 CSS 导航栏?