Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There are a couple of problems. First, the way you have created <code>dfrm</code>, <code>width</code> is a factor. </p> <pre><code>&gt; str(dfrm) 'data.frame': 125 obs. of 2 variables: $ width: Factor w/ 60 levels "106","20","21",..: 7 7 17 10 9 9 6 7 17 4 ... $ group: Factor w/ 4 levels "a","b","c","d": 1 1 1 1 1 1 1 1 1 1 ... </code></pre> <p>This is because <code>cbind</code> creates a matrix which must have all the same type and since there is a character, it is a character matrix. Later transformation to a data.frame makes them into factors. This can be fixed with</p> <pre><code>dfrm$width &lt;- as.numeric(as.character(dfrm$width)) </code></pre> <p>or better, not making matrices to begin with</p> <pre><code>df1 = data.frame(width=ceiling(rnorm(20, 30,5)), group='a') df2 = data.frame(width=ceiling(rnorm(40, 80,10)), group='b') df3 = data.frame(width=ceiling(rnorm(30, 50,8)), group='c') df4 = data.frame(width=ceiling(rnorm(35, 30,7)), group='d') dfrm = rbind(df1,df2,df3,df4) </code></pre> <p>This is enough to make a graph</p> <pre><code>ggplot(dfrm, aes(width, ..density.., colour = group)) + geom_freqpoly(binwidth = 1000) </code></pre> <p><img src="https://i.stack.imgur.com/K58EZ.png" alt="enter image description here"></p> <p>Though it looks like there is only one line, there are actually 4, all on top of each other. You only see the last one drawn (group "d"). This points out the second problem: your <code>binwidth</code> is way too large for this data.</p> <pre><code>ggplot(dfrm, aes(width, ..density.., colour = group)) + geom_freqpoly(binwidth = 10) </code></pre> <p><code>geom_freqpoly</code> does not appear to have a <code>fill</code> aesthetic, though.</p> <p><img src="https://i.stack.imgur.com/F4EgH.png" alt="enter image description here"></p>
    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.
    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.
    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