Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>FYI: This is more of an extended comment than an answer. </p> <p>To me, this new plot looks like a stacked bar where each bar's height is equal to the intersection points of the upper and lower line at the next trial. </p> <p><img src="https://i.stack.imgur.com/LKZQf.png" alt="enter image description here"></p> <p>The way that I would approach this is to treat "Trials" as a categorical variable. Then we can search each row of xcum for elements that are equal. If they are, then we can consider this to be a point of intersection whose minima also represents the multiple defining the height of our bars.</p> <pre><code>x &lt;- t(xcum) x &lt;- x[duplicated(x),] x[x==0] &lt;- NA </code></pre> <p>Now we have the multiples of the actual points, we need to figure out how to take it to the next step and find a way of binning the information. That means we need to make a decision about how many points will represent each grouping. Let's write some points out for posterity.</p> <pre><code>Trial 1 (2) = 1, 0.5 # multiple = 0.5 Trial 2 (3) = 1, 0.66, 0.33 # multiple = 0.33 Trial 3 (4) = 1, 0.75, 0.5, 0.25 # multiple = 0.25 Trial 4 (5) = 1, 0.8, 0.6, 0.4, 0.2 # multiple = 0.2 Trial 5 (6) = 1, 0.8333335, 0.6666668, 0.5000001, 0.3333334, 0.1666667 ... Trial 36 (35) = 1, 0.9722223, ..., 0.02777778 # mutiple = 0.05555556 / 2 </code></pre> <p>In other words, for each Trial there are n-1 points to plot. In your drawing you have 7 bins. So we need to figure out the multiples for each bin.</p> <p>Let's cheat and divide the last two columns by two, we know from visual inspection that the minima is lower than 0.05</p> <p><code>x[,35:36] &lt;- x[,35:36] / 2</code></p> <p>Then find the minimum of each column:</p> <pre><code>x &lt;- apply(x, 2, function(x) min(x, na.rm=T))[-1] # Drop the 1 x &lt;- x[c(1,2,3,4,8,17,35)] # I'm just guessing here by the "look" of your drawing. </code></pre> <p>The clearest way to do this is to create each bin separately. Obviously, this could be done automatically later. Remembering that each point is</p> <pre><code>bin1 &lt;- data.frame(bin = rep("bin1",2), Frequency = rep(x[1],2)) bin2 &lt;- data.frame(bin = rep("bin2",3), Frequency = rep(x[2],3)) bin3 &lt;- data.frame(bin = rep("bin3",4), Frequency = rep(x[3],4)) bin4 &lt;- data.frame(bin = rep("bin4",5), Frequency = rep(x[4],5)) bin5 &lt;- data.frame(bin = rep("bin5",9), Frequency = rep(x[5],9)) bin6 &lt;- data.frame(bin = rep("bin6",18), Frequency = rep(x[6],18)) bin7 &lt;- data.frame(bin = rep("bin7",36), Frequency = rep(x[7],36)) df &lt;- rbind(bin1,bin2,bin3,bin4,bin5,bin6,bin7) ggplot(df, aes(bin, Frequency, color=Frequency)) + geom_bar(stat="identity", position="stack") </code></pre>
    singulars
    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.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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