将给定的值(例如中值,iqr等)转换为箱线图

时间:2019-01-23 09:44:05

标签: r ggplot2

我想在每个distance的值上创建几个箱形图。问题是,我已经自己计算了箱线图的所有值,因此很多情况下我不想重复所有步骤来收集数据以自然地创建箱线图。 因此,有没有办法将我的中位数,iqr,最大值和最小值以及均值转换为箱线图?

数据:

structure(list(distance = c(50, 45, 40, 35, 30, 25, 20, 19, 18, 
17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0.9, 
0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.19, 0.18, 0.17, 0.16, 0.15, 
0.14, 0.13, 0.12, 0.11, 0.1, 0.09, 0.08, 0.07, 0.06, 0.05, 0.04, 
0.03, 0.02), median = c(0.7193121, 0.7193121, 0.7193121, 0.7193121, 
0.7193121, 0.7193121, 0.7193121, 0.7193121, 0.7193121, 0.7043872, 
0.7043872, 0.7043872, 0.7043872, 0.7043872, 0.7043872, 0.7043872, 
0.7043872, 0.7043872, 0.7043872, 0.7043872, 0.7043872, 0.6976425, 
0.7203216, 0.7203216, 0.7199486, 0.7003339, 0.6794477, 0.5876977, 
0.5455088, 0.4745327, 0.3928961, 0.3247046, 0.2402604, 0.1670641, 
0.1627094, 0.1520045, 0.138773, 0.123037, 0.1111772, 0.09881222, 
0.09631985, 0.08934352, 0.08633746, 0.08542623, 0.07180905, 0.05810843, 
0.05664605, 0.05375063, 0.03384152, 0.02390067, 0.01395982, 0
), mean = c(0.7413068, 0.7413068, 0.7413068, 0.7413068, 0.7413068, 
0.7413068, 0.7413068, 0.7413068, 0.7413068, 0.6913354, 0.6913354, 
0.6913354, 0.6913354, 0.6913354, 0.6913354, 0.6913354, 0.6913354, 
0.6913354, 0.6913354, 0.6913354, 0.6913354, 0.6842908, 0.6974025, 
0.6974025, 0.6939632, 0.667584, 0.6347348, 0.5574473, 0.515118, 
0.4421626, 0.3724864, 0.3020119, 0.2317612, 0.1540534, 0.1486486, 
0.1379508, 0.1286255, 0.1157533, 0.1062236, 0.09835248, 0.09214075, 
0.0857582, 0.07925751, 0.0765918, 0.06752173, 0.05540011, 0.05104472, 
0.04519633, 0.03010081, 0.02390067, 0.01395982, 0), iqr = c(0.3749765, 
0.3749765, 0.3749765, 0.3749765, 0.3749765, 0.3749765, 0.3749765, 
0.3749765, 0.3749765, 0.3746649, 0.3746649, 0.3746649, 0.3746649, 
0.3746649, 0.3746649, 0.3746649, 0.3746649, 0.3746649, 0.3746649, 
0.3746649, 0.3746649, 0.3779179, 0.3671259, 0.3671259, 0.3675734, 
0.3784318, 0.3081306, 0.2648424, 0.2119437, 0.1777727, 0.1436352, 
0.1137198, 0.07289936, 0.05379948, 0.05185602, 0.0574157, 0.05868708, 
0.05687079, 0.04522607, 0.0396385, 0.03395707, 0.02818766, 0.03263013, 
0.031834, 0.02873434, 0.01364959, 0.01656083, 0.01847473, 0.01427064, 
0.009940847, 0, 0), max = c(17.77844208, 17.77844208, 17.77844208, 
17.77844208, 17.77844208, 17.77844208, 17.77844208, 17.77844208, 
17.77844208, 5.36268142, 5.36268142, 5.36268142, 5.36268142, 
5.36268142, 5.36268142, 5.36268142, 5.36268142, 5.36268142, 5.36268142, 
5.36268142, 5.36268142, 4.34970133, 2.4067181, 2.4067181, 1.8043306, 
0.99891794, 0.89878447, 0.799641, 0.69938204, 0.5999397, 0.49977768, 
0.39957404, 0.29975985, 0.19987412, 0.18979907, 0.17988976, 0.16821759, 
0.15954502, 0.14899043, 0.13877301, 0.12997926, 0.11962987, 0.10877292, 
0.0995132, 0.08934352, 0.07843555, 0.0676996, 0.05902917, 0.04250111, 
0.03384152, 0.01395982, 0), min = c(0.09465671, 0.09465671, 0.09465671, 
0.09465671, 0.09465671, 0.09465671, 0.09465671, 0.09465671, 0.09465671, 
0.09465671, 0.09465671, 0.09465671, 0.09465671, 0.09465671, 0.09465671, 
0.09465671, 0.09465671, 0.09465671, 0.09465671, 0.09465671, 0.09465671, 
0.09465671, 0.1058249, 0.1058249, 0.1058249, 0.09465671, 0.06355059, 
0.06355059, 0.06355059, 0.08301156, 0.03384152, 0.05902917, 0.01395982, 
0.01395982, 0.01395982, 0.01395982, 0.01395982, 0.01395982, 0.01395982, 
0.01395982, 0.01395982, 0.01395982, 0.01395982, 0.01395982, 0.01395982, 
0.01395982, 0.01395982, 0.01395982, 0.01395982, 0.01395982, 0.01395982, 
0), std = c(0.8864041, 0.8864041, 0.8864041, 0.8864041, 0.8864041, 
0.8864041, 0.8864041, 0.8864041, 0.8864041, 0.3319887, 0.3319887, 
0.3319887, 0.3319887, 0.3319887, 0.3319887, 0.3319887, 0.3319887, 
0.3319887, 0.3319887, 0.3319887, 0.3319887, 0.309771, 0.2485103, 
0.2485103, 0.2365996, 0.2317995, 0.1994314, 0.1760748, 0.1430734, 
0.1230979, 0.09761741, 0.07779096, 0.05218991, 0.04028708, 0.03806269, 
0.03837218, 0.03581113, 0.03550626, 0.03184689, 0.02945863, 0.02708977, 
0.0247326, 0.02246103, 0.02188115, 0.02061182, 0.01807177, 0.01650302, 
0.01652885, 0.01463372, 0.01405848, 0, 0)), .Names = c("distance", 
"median", "mean", "iqr", "max", "min", "std"), row.names = c(NA, 
-52L), class = "data.frame")

0 个答案:

没有答案