shiny - geom_smooth 未显示在 ggplot 函数中
问题描述
我正在尝试添加geom_smooth(method = 'loess')
,但这并没有出现在情节中。我相信这与数值有关,geom_smooth 没有将输入识别为数字?
> head(CH12F3.miRNA_prep.miRNA)
miRNA variable value
1 mmu-let-7a-1-3p 0h 0.5098628
2 mmu-let-7a-5p 0h 0.4286451
3 mmu-let-7b-3p 0h 0.0000000
4 mmu-let-7b-5p 0h 1.4925830
5 mmu-let-7c-2-3p 0h 1.0715206
6 mmu-let-7c-5p 0h 1.3836720
server <- function(input, output, session) {
data_selected <- reactive({
filter(CH12F3.miRNA_prep.miRNA, miRNA %in% input$MicroRNA)
})
output$myplot <- renderPlot({
ggplot(data_selected(), aes_string("variable", "value", colour = "variable")) +
geom_point() + theme_classic(base_size = 12) +
labs(colour="Time Point",x="Time",y="Expression (cpm,log2)\nTreated/Control")+
theme(axis.text.x = element_text(angle = 45,hjust = 1)) + geom_smooth(method = 'loess')
} )
}
解决方案
在您的ggplot
, 尝试aes(as.numeric(variable), as.numeric(value), color=variable)
而不是aes_string()
.
推荐阅读
- r - 如何在 r 中重复 For 循环?
- javascript - 在侧边栏中向下滚动的侧边栏菜单
- jsonpath - jsonPath 谓词返回整个 JSON
- java - E/SQLiteLog: (1) 表 Estudiantes 在 android 中没有名为 calificacion 的列
- mysql - MYSQL 查询仅选择具有过期日期的最新数据行集
- date - 如何使用 COUNTIFS 计算设定日期后的事件?
- spartacus-storefront - 如何使用自定义解析器添加自定义元数据,如 PageTitleResolver 、 PageDescriptionResolver 等
- c - 为什么这个表达式在 C 中变成 4?
- asp.net-core - 在 .NET Core 3.1 控制台中托管 SignalR 集线器
- excel - ActiveX 文本框在单击设计视图之前不会更新