Skip to content

Instantly share code, notes, and snippets.

@dcomtois
Created April 11, 2018 08:28
Show Gist options
  • Save dcomtois/e7497f3e3e75b671020b116bbd11e676 to your computer and use it in GitHub Desktop.
Save dcomtois/e7497f3e3e75b671020b116bbd11e676 to your computer and use it in GitHub Desktop.
Rmarkdown - question on StackOverflow about lists
---
title: "Rendering a list of objects in Rmarkdown"
author: "Dominic Comtois"
date: "`r Sys.Date()`"
output:
rmarkdown::html_vignette:
css:
- !expr system.file("rmarkdown/templates/html_vignette/resources/vignette.css", package = "rmarkdown")
- !expr system.file("includes/stylesheets/summarytools.css", package = "summarytools")
---
# Prerequisite
```r
devtools::install_github('dcomtois/summarytools', ref = 'dev-current')
```
# Setup
```{r setup, include=TRUE}
library(knitr)
opts_chunk$set(comment=NA, prompt=FALSE, cache=FALSE, results = 'asis')
library(summarytools)
st_options('footnote', NA)
st_options('plain.ascii', FALSE)
```
## The problem
Those sneaky `[[n]]` indices...
```{r groupstats_html}
groupstats <- by(data = exams, INDICES = exams$gender, FUN = descr, stats = c("mean", "sd", "min", "med", "max"))
view(groupstats, method = 'render')
```
This gives similar results:
```r
lapply(groupstats, print, method = 'render')
```
## Markdown rendering is fine using view() function
```{r groupstats_md}
view(groupstats, method = 'pander')
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment