Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>what about:</p> <pre><code>&gt; swiss$qEdu &lt;- cut (swiss$Education, breaks = quantile (swiss$Education, c (0, .25, .5, .75, 1)), include.lowest = TRUE) &gt; aggregate (swiss$Infant.Mortality, list (qEdu = swiss$qEdu), FUN = mean) qEdu x 1 [1,6] 19.31429 2 (6,8] 21.93636 3 (8,12] 19.38182 4 (12,53] 19.30909 </code></pre> <p>(I don't really know what your numbers are - they don't coincide with the averages I get)</p> <p>(That was before the edit...)</p> <p>(After 2nd edit:) If you want the Infant.Mortality for each of the provinces belongig to that quartile of Eduction, use <code>list ()</code> as aggregation function:</p> <pre><code>&gt; aggregate (swiss$Infant.Mortality, list (qEdu = swiss$qEdu), FUN = list) qEdu x 1 [1,6] 20.2, 24.5, 18.7, 21.2, 22.4, 15.3, 21.0, 18.0, 15.1, 19.8, 18.3, 19.4, 20.2, 16.3 2 (6,8] 20.3, 26.6, 23.6, 24.9, 21.0, 19.1, 20.0, 23.8, 22.5, 20.0, 19.5 3 (8,12] 22.2, 22.2, 16.5, 22.7, 20.0, 18.0, 16.7, 16.3, 17.8, 20.3, 20.5 4 (12,53] 20.6, 24.4, 20.2, 10.8, 20.9, 18.1, 18.9, 23.0, 18.0, 18.2, 19.3 </code></pre> <p>or:</p> <pre><code>&gt; Infant.Mortality &lt;- lapply (levels (swiss$qEdu), function (x) swiss$Infant.Mortality [swiss$qEdu == x]) &gt; names (Infant.Mortality) &lt;- levels (swiss$qEdu) &gt; Infant.Mortality $`[1,6]` [1] 20.2 24.5 18.7 21.2 22.4 15.3 21.0 18.0 15.1 19.8 18.3 19.4 20.2 16.3 $`(6,8]` [1] 20.3 26.6 23.6 24.9 21.0 19.1 20.0 23.8 22.5 20.0 19.5 $`(8,12]` [1] 22.2 22.2 16.5 22.7 20.0 18.0 16.7 16.3 17.8 20.3 20.5 $`(12,53]` [1] 20.6 24.4 20.2 10.8 20.9 18.1 18.9 23.0 18.0 18.2 19.3 </code></pre>
 

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