title: Wanting to take the highest and lowest 25% of a table
body: <p>Hello as far as I could find there is no real solution for my task yet. (If there is please just let me know and I will take advice from there)</p>
  <p>But without writing more unnecessary now:
  I would like to get the highest and lowest 25% (or other percentages possible) values from a table (example see below). This involves several columns (4 to be exact) that have the highest and lowest values.</p>
  <p>About my data:
  Have a panel regression (with time series), which I analyze by <code>influence.measures</code>. This function gives the extreme values (similar to <code>gvlma</code>).</p>
  <p>Then, since the number is quite high (+300 for a dataset of almost 3600 variables (or is this not much?)) I want to remove only the highest 25% and lowest 25% of the variables, from the table.
  My function for this is as follows:</p>
  <pre><code>lm.01 &lt;-lm(log(x) ~ log(intr) + log(y) + log(z) + factor(dummy)
             , data=r1.2) 
  
  unnecessary_data1 &lt;- influence.measures(lm.01)
  table_u_d1 &lt;- summary(unnecessary_data1)
  
  drops1.2 &lt;- c()
  #in c() should the variables be included that should get excluded
  
  r1.2 = r1.1
  #r is my data set
  
  r1.2 &lt;- r1.2[-drops1.2,]
  </code></pre>
  <p>Output of <code>table_u_d1</code> looks something like this (only the columns that should be necessary (there are more but those are not relevant):</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th></th>
  <th>example row</th>
  <th>dffit</th>
  <th>cov.r</th>
  <th>cook.d</th>
  <th>hat</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>9</td>
  <td>-0.003754</td>
  <td>-0.11643</td>
  <td>0.972833</td>
  <td>0.000972</td>
  <td>0.001587</td>
  </tr>
  <tr>
  <td>10</td>
  <td>-0.056679</td>
  <td>-0.09812</td>
  <td>0.985349</td>
  <td>0.000693</td>
  <td>0.000687</td>
  </tr>
  <tr>
  <td>100</td>
  <td>0.005639</td>
  <td>-0.23096</td>
  <td>0.995242</td>
  <td>0.003839</td>
  <td>0.010623</td>
  </tr>
  <tr>
  <td>301</td>
  <td>0.006557</td>
  <td>-0.24344</td>
  <td>0.993736</td>
  <td>0.004269</td>
  <td>0.010729</td>
  </tr>
  <tr>
  <td>490</td>
  <td>-0.003771</td>
  <td>-0.26348</td>
  <td>1.015349</td>
  <td>0.004991</td>
  <td>0.010783</td>
  </tr>
  <tr>
  <td>510</td>
  <td>-0.020162</td>
  <td>-0.23365</td>
  <td>1.014367</td>
  <td>0.003869</td>
  <td>0.010551</td>
  </tr>
  <tr>
  <td>530</td>
  <td>-0.007013</td>
  <td>0.07778</td>
  <td>1.005749</td>
  <td>0.004319</td>
  <td>0.012449</td>
  </tr>
  <tr>
  <td>720</td>
  <td>-0.015032</td>
  <td>-0.06255</td>
  <td>1.010301</td>
  <td>0.001425</td>
  <td>0.010034</td>
  </tr>
  <tr>
  <td>1120</td>
  <td>-0.003564</td>
  <td>-0.04462</td>
  <td>1.019249</td>
  <td>0.000053</td>
  <td>0.010329</td>
  </tr>
  <tr>
  <td>1320</td>
  <td>0.000003</td>
  <td>-0.00134</td>
  <td>1.025679</td>
  <td>0.004878</td>
  <td>0.010186</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>I need the value of the first column as the result, because this indicates the position in the regression and only so I can use drops. And I need the values that have the highest and lowest 25% values in <code>dffit</code>, <code>cov.r</code>, <code>cook.d</code> and <code>hat</code>.</p>
  <p>Maybe it could be useful for the exemplary data set that not the top and bottom 25% are used, but less. Need but please also a solution with 25% :).</p>
  <p>If any further information are needed just let me know :)</p>
  <p>Need help to loop and to get the final information
  I have found now this way to get the information:</p>
  <pre><code>dffit.75.1&lt;-data.frame(table_u_d1) %&gt;% 
    filter(quantile(dffit, 0.75)&lt;dffit)
  dffit.25.1&lt;-data.frame(table_u_d1) %&gt;% 
    filter(quantile(dffit, 0.25)&gt;dffit)
  
  cov.r.75.1&lt;-data.frame(table_u_d1) %&gt;% 
    filter(quantile(cov.r, 0.75)&lt;cov.r)
  cov.r.25.1&lt;-data.frame(table_u_d1) %&gt;% 
    filter(quantile(cov.r, 0.25)&gt;cov.r)
  
  cook.d.75.1&lt;-data.frame(table_u_d1) %&gt;% 
    filter(quantile(cook.d, 0.75)&lt;cook.d)
  cook.d.25.1&lt;-data.frame(table_u_d1) %&gt;% 
    filter(quantile(cook.d, 0.25)&gt;cook.d)
  
  hat.75.1&lt;-data.frame(table_u_d1) %&gt;% 
    filter(quantile(hat, 0.75)&lt;hat)
  hat.25.1&lt;-data.frame(table_u_d1) %&gt;% 
    filter(quantile(hat, 0.25)&gt;hat)
  </code></pre>
  <p>But afterwards it does not help to get a complete data</p>
  <pre><code>dffit.1&lt;-rbind(dffit.25.1,dffit.75.1)
  cov.r.1&lt;-rbind(cov.r.25.1,cov.r.75.1)
  ....
  </code></pre>
  <p>Because the output would just always double the amount of the data (so duplicates are not recognised)</p>