【发布时间】:2020-07-18 22:29:26
【问题描述】:
我收到错误:stat_count() 只能具有 x 或 y 美学。尝试使用 Excel 工作表中的数据进行绘图时
library(readxl)
library(dplyr)
library(ggplot2)
dataset= read_excel("D:/Downloads/Covid19.xlsx")
dataset2= read_excel("D:/Downloads/Covid19.xlsx", sheet = "Sheet2")
dataset3= dataset[,c(4,5)]
ggplot(dataset2, aes(x=Region, y= male))+geom_bar()
我的 excel 文件中的数据如下所示 Dataset
【问题讨论】:
-
或者
geom_col -
@sahwahn 成功了
-
如果我想在图表中同时添加男性和女性值怎么办? @sahwahn
-
您需要将数据重新格式化为长格式 - 这应该解释它r-graph-gallery.com/48-grouped-barplot-with-ggplot2.html
-
@sahwahn 是否有适合初学者的简单方法?这对我来说都是保镖
标签: r