r - 标签的侧箱图比较
问题描述
这是我的数据集dput_data
。
dput_data <- structure(list(Label = c(" Flight", " Flight", " Flight", " Flight",
" Flight", " Ground Control", " Ground Control", " Ground Control",
" Ground Control", " Ground Control", " Ground Control"), `210885` = c(2.46726120893655,
-0.174636990542105, -0.463404328357544, 2.3996395908089, -0.150507030748742,
5.64497005685753, 3.36669883823842, 0.0291245138878325, -0.0720040453347311,
1.23592496897254, -0.435680321628551), `110647` = c(-0.183451995597915,
-0.232101174582698, -0.418549509261665, 3.12474114229781, -0.963627404680163,
-0.295591624345765, 3.74110668642539, -0.307620588051106, 4.95070981495709,
-0.248418667713625, 0.556071497195402), `120996` = c(2.958740197185,
-0.658764097795927, -0.720985892268865, -0.605140415143121, -0.614856607147667,
2.84170000321244, 2.4703391289031, 1.89042697528755, 1.38117056072924,
2.66548725562505, -0.775258323014181)), class = "data.frame", row.names = c(35L,
36L, 37L, 38L, 39L, 44L, 45L, 46L, 47L, 48L, 49L))
看起来像这样
Label 210885 110647 120996
35 Flight 2.46726121 -0.1834520 2.9587402
36 Flight -0.17463699 -0.2321012 -0.6587641
37 Flight -0.46340433 -0.4185495 -0.7209859
38 Flight 2.39963959 3.1247411 -0.6051404
39 Flight -0.15050703 -0.9636274 -0.6148566
44 Ground Control 5.64497006 -0.2955916 2.8417000
45 Ground Control 3.36669884 3.7411067 2.4703391
46 Ground Control 0.02912451 -0.3076206 1.8904270
47 Ground Control -0.07200405 4.9507098 1.3811706
48 Ground Control 1.23592497 -0.2484187 2.6654873
49 Ground Control -0.43568032 0.5560715 -0.7752583
目前我已经尝试过:
library(reshape2)
dput_dat <- melt(dput_data, id.vars = 'Label', measure.vars = c('210885', '110647', '120996'))
library(ggplot2)
ggplot(dput_dat) + geom_boxplot(aes(y=value, color=variable)) + facet_grid(.~`Label`)
这给了我两组箱线图,一组是飞行的,另一组是地面控制的。
但我更喜欢将箱线图放在一起210885
Flight
,Ground Control
这样我就可以进行直接的并排比较(飞行和地面控制使用不同的颜色)。同样适用于110647
and 120996
。所有这些都在图表中。
我对如何进行有点不知所措。
解决方案
推荐阅读
- python - 不能在 pycharm 中使用 ggplot 但 spyder 可以
- google-sheets - 如何在 Google 电子表格 API v4 中读取最后更新的行
- javascript - 在sails.js 中上传多个文件
- javascript - 在收到的 Woocommerce 订单上的 javascript 中设置订单 ID 和订单总额
- python - 任意数量字典的笛卡尔积的总和
- r - R Shiny:slickR 选择事件
- c++ - 是否有任何有效的方法来填充平衡的树结构
- ios - iOS - 链接一个部署目标比我的项目更高的框架
- jquery - 从前端更新数据库表
- lua - 如何在 luacheck 中将警告设为错误?