title: Rmarkdown - printing a list of objects without showing those pesky [[indices]]
body: <p>This will be a little wordy, as without proper context I cannot see how I can ask my question. </p>
  
  <p>Without going too much into details, in my <code>summarytools</code> package, I have dealt with <code>by()</code> objects by using a wrapper function for <code>print.summarytools</code>, namely <code>view()</code>. This <code>view()</code> function can identify objects created through <code>by</code> or <code>lapply()</code>, and dispatch its components to the package's <code>print()</code>, with appropriate arguments relating to headings and footnotes, and so on (the first element will not receive the same arguments as the second, nor the last).</p>
  
  <p>Link to package dev page: </p>
  
  <p>The package offers two ways of rendering content: rmarkdown through <code>pander</code>, and HTML with RStudio's <code>htmltools</code>. As far as rmarkdown/pander is concerned, I have achieved satisfying results. The same cannot be said about the HTML rendering inside rmarkdown documents.</p>
  
  <h2>For example:</h2>
  
  <pre><code>library(devtools)
  install_github("dcomtois/summarytools", ref = "dev-current")
  library(summarytools)
  
  # call the descr() function through by() to get stats by gender
  groupstats &lt;- by(data = exams, INDICES = exams$gender, FUN = descr)
  
  # Use the view() function to neatly display results
  view(groupstats, method = 'render')
  </code></pre>
  
  <p>This example is available as a <a href="https://gist.githubusercontent.com/dcomtois/e7497f3e3e75b671020b116bbd11e676/raw/007ec05f4caa1d8aa343ef729b29f45cb3d3e819/rendering_lists.Rmd" rel="nofollow noreferrer">Gist on github</a>.</p>
  
  <h2>Results after knitting:</h2>
  
  <p><a href="https://i.stack.imgur.com/S2mYs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/S2mYs.png" alt="rendered html content"></a></p>
  
  <p>I have tried several things, none satisfactory. Since the objects returned by summarytool's print method are of class <code>shinytag</code>, the (maybe) ideal solution would be to combine all of those into one list of class <code>shinytag</code>, but I'm not aware of any way to do that with <code>htmltools</code>. And handpicking the list elements appears to me as a recipe for trouble, since the is a whole lot of list-nesting in there.</p>
  
  <p>I tried <code>lapply(groupstats, print, method = 'render')</code>, but then instead of having <code>[[n]]</code>'s, I have <code>$names</code> showing up.</p>
  
  <p><strong>So my question is</strong>: How can I possibly get rid of the <code>[[n]]</code>'s in the output?  </p>
  
  <p><strong>Package source code</strong>
  For the relavant chuck of the package source code, see in <a href="https://github.com/dcomtois/summarytools/tree/dev-current" rel="nofollow noreferrer">summarytool's dev-current branch</a> the <code>R/view.R</code> file, line ~ 78 -116.</p>