title: Making an ordered Factor
body: <p>The following code creates a vector called sizes from small to extra-large</p>
  <pre><code>set.seed(23)
  sizes&lt;-sample(c(&quot;small&quot;,&quot;medium&quot;,&quot;large&quot;,&quot;extra-large&quot;),50,replace=T)
  </code></pre>
  <p>Here I made the attempt to create ordered levels by first creating the factor and then use order to the factor I have created. When displaying the output, I see that they are separated by size. How can I create four order pairs, where small is less than medium, the medium is less than large, and large is less than extra-large?</p>
  <pre><code>sizes_as_factor = factor(x=c(sizes))
  sizes[order(sizes_as_factor)]
  </code></pre>