r - 使用ggplot没有显示并排的栏
问题描述
我的问题与这个有关: 条形图中的并排条 我正在尝试做同样的事情,但我没有得到任何数据,轴已填充。但没有可视化图表。我试图以小步骤重新修改数据,但仍然没有成功。我不知道,为什么没有显示数据。
n<-15
data <- data.frame("number" = c(1:n),
"Nasal" = c(15.4, 13.5, 13.3, 12.4, 12.8,
13.5, 14.5, 13.9, 11.0, 15.0,
17.0, 13.8, 17.4, 16.5, 14.4),
"Endob" = c(16.5, 13.2, 13.6, 13.6, 14.0,
14.0, 16.0, 14.1, 11.5, 14.4,
16.0, 13.2, 16.6, 18.5, 14.5))
library(ggplot2)
method<-rep(c("Nasal","Endob"),each=n)
values<-c(data$Nasal, data$Endob)
patient<-factor(c(1:15))
data2<- data.frame(patient,method,values)
data2
ggplot(data2, aes(x=factor(patient), fill=method, y=values))
geom_bar(position ="dodge",stat="identity")
解决方案
我认为它运行良好,你只是忘记了and+
之间的关系。ggplot
geom_bar
ggplot(data2, aes(x=factor(patient), fill=method, y=values)) +
geom_bar(position ="dodge",stat="identity")
推荐阅读
- reactjs - 如何折叠数据表?
- java - 有没有办法“刷新” Springframework Repository?
- dictionary - SASS 地图必须在一条线上吗?
- apache-spark - 如何在pyspark中读取二进制数据
- java - 链接多个 GLES 2.0 程序
- r - 检查一个 data.table 列中的所有元素以查看另一个 data.table 列中每个值出现的最快方法
- neo4j - Neo4j 我可以对关系进行排序吗?
- ios - 是否可以使用 Swift 或 Objective-c 从 iOS 上的本机应用程序将语音流式传输到 Directline API
- python - 没有子类化的最基本的日志处理程序
- assembly - 如何使用 nasm 编译 x86 汇编代码?我收到一个错误