title: How can I return compact head() and tail() results from the same code line with Rmarkdown/Knitr?
body: <p><b>Goal:</b>  I want to return adjacent or at least compact results for <code>head()</code> and <code>tail()</code> using one line of code in Rmarkdown/Knitr.</p>
  
  <p>I realize I can use <code>c()</code> for certain functions on the same code line and print on the same result line, e.g., <code>c(mean(vector), sd(vector))</code> will return <code>## [1] 20.663  6.606</code>.</p>
  
  <p>However, if I try <code>c(head(data), tail(data))</code> I get a list, instead of a matrix/df and if I use <code>head(data); tail(data)</code> the results will display contiguously(?) top/bottom in the R console but return only <code>tail(data)</code> results in Rmarkdown/Knitr.</p>
  
  <p><b>Repro steps:</b></p>
  
  <ol>
  <li><p>Create an Rmd file with the following R chunk:</p>
  
  <pre><code>```{r Load Data, cache=TRUE,echo=TRUE}
  
  require("datasets") ## ensure User has the R datasets package installed
  data("ToothGrowth") ## load the ToothGrowth dataset
  head(ToothGrowth, n = 2); tail(ToothGrowth, n = 2) ## attempt compact results
  
  ```
  </code></pre></li>
  <li><p>Ctrl+shift+k to knit the Rmd or otherwise select the Knit HTML action.</p></li>
  </ol>
  
  <p><b>Relevant result:</b>  </p>
  
  <pre><code>    ##    len    supp dose
      ## 59 29.4   OJ    2
      ## 60 23.0   OJ    2
  </code></pre>
  
  <p><b>FYI settings:</b></p>
  
  <pre><code>sessionInfo()
  R version 3.0.2 (2013-09-25)
  Platform: x86_64-w64-mingw32/x64 (64-bit)
  
  locale:
  [1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
  [3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
  [5] LC_TIME=English_United States.1252    
  
  attached base packages:
  [1] stats     graphics  grDevices utils     datasets  methods   base     
  
  loaded via a namespace (and not attached):
  [1] digest_0.6.4     evaluate_0.5.3   formatR_0.10     htmltools_0.2.4  knitr_1.6       
  [6] rmarkdown_0.2.46 stringr_0.6.2    tools_3.0.2      yaml_2.1.11
  </code></pre>