Note that there are some explanatory texts on larger screens.

plurals
  1. POBinning a dataframe with equal frequency of samples
    primarykey
    data
    text
    <p>I have binned my data using the cut function</p> <pre><code>breaks&lt;-seq(0, 250, by=5) data&lt;-split(df2, cut(df2$val, breaks)) </code></pre> <p>My split dataframe looks like</p> <pre><code>... ... $`(15,20]` val ks_Result c 15 60 237 18 70 247 ... ... $`(20,25]` val ks_Result c 21 20 317 24 10 140 ... ... </code></pre> <p>My bins looks like</p> <pre><code>&gt; table(data) data (0,5] (5,10] (10,15] (15,20] (20,25] (25,30] (30,35] 0 0 0 7 128 2748 2307 (35,40] (40,45] (45,50] (50,55] (55,60] (60,65] (65,70] 1404 11472 1064 536 7389 1008 1714 (70,75] (75,80] (80,85] (85,90] (90,95] (95,100] (100,105] 2047 700 329 1107 399 376 323 (105,110] (110,115] (115,120] (120,125] (125,130] (130,135] (135,140] 314 79 1008 77 474 158 381 (140,145] (145,150] (150,155] (155,160] (160,165] (165,170] (170,175] 89 660 15 1090 109 824 247 (175,180] (180,185] (185,190] (190,195] (195,200] (200,205] (205,210] 1226 139 531 174 1041 107 257 (210,215] (215,220] (220,225] (225,230] (230,235] (235,240] (240,245] 72 671 98 212 70 95 25 (245,250] 494 </code></pre> <p>When I mean the bins, I get on an average of ~900 samples</p> <pre><code>&gt; mean(table(data)) [1] 915.9 </code></pre> <p>I want to tell R to make irregular bins in such a way that each bin will contain on an average 900 samples (e.g. (0, 27] = 900, (27,28.5] = 900, and so on). I found something similar <a href="https://stackoverflow.com/questions/5731116/equal-frequency-discretization-in-r">here</a>, which deals with only one variable, not the whole dataframe.</p> <p>I also tried Hmisc package, unfortunately the bins don't contain equal frequency!! </p> <pre><code>library(Hmisc) data&lt;-split(df2, cut2(df2$val, g=30, oneval=TRUE)) data&lt;-split(df2, cut2(df2$val, m=1000, oneval=TRUE)) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload