mercredi 20 mars 2019

Generate a vector to conditionally separate equal values by specified intervals in R

Consider the vector of numbers below

c(8.29, 11.23, 11.23, 8.82, 8.82, 11.23, 7.4, 10.05, 10.05, 7.19, 
7.4, 10.05, 3.82, 4.34, 4.34, 4.11, 4.11, 4.34, 3.66, 4.25, 4.25, 
3.95, 3.95, 4.25, 112.6, 124.6, 124.6, 123.2060887, 123.2060887, 
124.6, 142.8, 142.8, 126.4, 149.1772336, 149.1772336, 149.1772336, 
12.33333333, 12.33333333, 10.5, 12.33333333, 10.5, 8.611, 13, 
8.833333333, 13, 6.166666667, 13, 8.833333333, 8.4934, 18.858, 
18.858, 18.93, 18.93, 18.93, 8.2369, 18.64, 18.64, 14.845, 14.845, 
18.64, 5.6405, 5.6405, 4.914, 5.6405, 4.914, 3.3356, 8.6466, 
8.6466, 6.3472, 8.6466, 6.8782, 6.8782, 234.8436611, 279.8109002, 
279.8109002, 240.7415593, 240.7415593, 279.8109002, 175.3816258, 
252.6242588, 252.6242588, 145.2245835, 175.3816258, 252.6242588, 
58.47020984, 81.85080837, 440.0126793, 641.6917085, 641.6917085, 
438.09328, 440.0126793, 641.6917085, 333.2871061, 461.7888531, 
461.7888531, 259.4327562, 333.2871061, 461.7888531, 72.80259873, 
42.76565047, 72.80259873, 74.72707421, 74.72707421, 74.72707421) 

These are max values of a series of comparisons. I want to use them to place significance bars in plots of all these comparisons at a specified y-value. Something like this, where the significance bar will be placed between groups at this y-value.

Something like this

I want to generate this y-value vector such that each of the values is higher by 2 - 3 than its corresponding max value when that value is 0-10, by 4-5 when 10-100, and by 10 when > 100.

Several values in the max value vector are the same, so just adding a certain number will not work, as I cannot obtain the separation I want to achieve. I can provide more details if that will help clarify the issue. Thanks.




Aucun commentaire:

Enregistrer un commentaire