title: Problem with sort() and knit function in R
body: <p><strong>Problem:</strong>
  I have an .Rmd file of an analysis that I'm trying to knit without success. I've created a toy example of the code that is causing the knit to fail. I am able to execute this example code chunk in R:</p>
  
  <pre><code>subject &lt;- c('1', '3', '2')
  run &lt;- as.factor(c('run1', 'run2', 'run3'))
  sample_df &lt;- data.frame(subject, run)
  sorted_df &lt;- sample_df[ order(subject, run), ]
  kable(sorted_df)
  </code></pre>
  
  <p>With the following output returned:</p>
  
  <pre><code>|   |subject |run  |
  |:--|:-------|:----|
  |1  |1       |run1 |
  |3  |2       |run3 |
  |2  |3       |run2 |
  </code></pre>
  
  <p>However, when I attempt to knit the document, the knit fails with the following error:</p>
  
  <p><a href="https://i.stack.imgur.com/RqM2x.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RqM2x.png" alt="error message"></a></p>
  
  <p>The rest of the document does knit successfully with this code removed.</p>
  
  <p><strong>Additional info:</strong></p>
  
  <pre><code>&gt; version
                 _                           
  platform       x86_64-apple-darwin15.6.0   
  arch           x86_64                      
  os             darwin15.6.0                
  system         x86_64, darwin15.6.0        
  status                                     
  major          3                           
  minor          5.1                         
  year           2018                        
  month          07                          
  day            02                          
  svn rev        74947                       
  language       R                           
  version.string R version 3.5.1 (2018-07-02)
  nickname       Feather Spray   
  </code></pre>