Created
April 11, 2018 08:28
-
-
Save dcomtois/e7497f3e3e75b671020b116bbd11e676 to your computer and use it in GitHub Desktop.
Rmarkdown - question on StackOverflow about lists
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
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