具有多个条形的条形图
我有一个包含多个列的大型数据集。现在我想制作一个条形图来可视化结果,我将首先制作一个看起来像我的数据集
age <- ("18-30","31-45","60+","46-60", "31-45", "18-30", "60+", "46-60")
gender <- ("M","F","F","F","M","M","F","M")
case <- ("Q1","Q1","Q2","Q2","Q3","Q3","Q4","Q4")
height <- (0,200,310,0,0,175,270,150)
现在我想制作一个条形图,其中 x 轴上有 4 个案例,Y 轴上有平均高度,两个不同的 M 和 F 条表示平均高度。 它应该看起来像这样: 除了使用 barplot() 之外,我真的不知道如何开始或做什么,任何人都可以帮忙吗?
i have a large dataset with several columns. now i would like to make a barplot to visualise the results, I will first make a dataset that looks like mine
age <- ("18-30","31-45","60+","46-60", "31-45", "18-30", "60+", "46-60")
gender <- ("M","F","F","F","M","M","F","M")
case <- ("Q1","Q1","Q2","Q2","Q3","Q3","Q4","Q4")
height <- (0,200,310,0,0,175,270,150)
Now i would like to make a barplot with on the x-axis the 4 cases, on the Y-axis the average height, and two different bars for M and F indicating the average height.
it should look like this:
except for using the barplot(), I don't really know how to start or what to do, can anyone help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以这样做:将矢量放入 tibble 中,以便您可以轻松地将它们传递给您的 ggplot() 调用。
You could do like this: Put your vectors into a tibble so that you can easily pass them to your
ggplot()
call.