简体   繁体   English

一张图中的多个箱线图,R

[英]Multiple boxplots in one graph, R

I'm working with a dataset where I have one continous variable (V1) and want to see how that variable differs depending on demographics such as sex, age group etc.我正在使用一个数据集,其中我有一个连续变量 (V1),并希望了解该变量如何根据性别、年龄组等人口统计数据而有所不同。

I would like to do one graph that contains multiple boxplots - so that V1 is on the Y-axis and all my demographic variables (sex, age groups etc.) are on the x-axis with their corresponding p-values.我想做一个包含多个箱线图的图表 - 使 V1 在 Y 轴上,我的所有人口统计变量(性别、年龄组等)都在 x 轴上,并带有相应的 p 值。 Anyonw know how to do this in R? Anyonw 知道如何在 R 中执行此操作吗?

I've added two photos to illustrate my dataset and the output I want.我添加了两张照片来说明我的数据集和我想要的 output。

Thanks!谢谢!

Output example Output 示例1

Data example数据示例

2

It would be nice to have actual data and the code you already have so we can replicate what you have and work what you want.拥有实际数据和您已经拥有的代码会很好,这样我们就可以复制您拥有的内容并按照您的意愿工作。 That being said, this link might be what you are looking for:话虽如此,此链接可能是您正在寻找的内容:

https://statisticsglobe.com/draw-multiple-boxplots-in-one-graph-in-r#example-2-drawing-multiple-boxplots-using-ggplot2-package https://statisticsglobe.com/draw-multiple-boxplots-in-one-graph-in-r#example-2-drawing-multiple-boxplots-using-ggplot2-package

Scroll down about half way to Example 4: Drawing Multiple Boxplots for Each Group Side-by-Side向下滚动大约一半到示例 4:并排为每个组绘制多个箱线图

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM