https://github.com/kaneplusplus/listdown
https://kaneplusplus.github.io/listdown
https://github.com/kaneplusplus/listdown
Last synced: 11 days ago
JSON representation
https://kaneplusplus.github.io/listdown
- Host: GitHub
- URL: https://github.com/kaneplusplus/listdown
- Owner: kaneplusplus
- License: other
- Created: 2020-01-20T03:22:49.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-03-27T15:34:20.000Z (about 2 years ago)
- Last Synced: 2025-03-15T14:04:19.401Z (about 1 month ago)
- Language: TeX
- Homepage:
- Size: 2.6 MB
- Stars: 27
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: NEWS.md
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- jimsghstars - kaneplusplus/listdown - https://kaneplusplus.github.io/listdown (TeX)
README
# listdown
[](https://cran.r-project.org/package=listdown)
[](https://github.com/kaneplusplus/listdown/actions)
[](https://codecov.io/gh/kaneplusplus/listdown?branch=master)## Overview
The {listdown} package provides functions to programmatically create R
Markdown files from named lists. It is intended for data analysis
pipelines where the presentation of the results is separated from their
creation. For this use case, a data processing (or analysis) is
performed and the results are provided in a single named list, organized
hierarchically. With the list and a {listdown} object a workflowr, pdf,
word, or html page. List element names denote sections, subsections,
subsubsection, etc. and the list elements contain the data structure to
be presented including graphs and tables. The goal of the package is not
to provide a finished, readable document. It is to provide a document
with all tables and visualization that will appear (*computational*
components). This serves as a starting point from which a user can
organize outputs, describe a study, discuss results, and provide
conclusions (*narrative* components).{listdown} provides a reproducible means for producing a document with
specified computational components. It is most compatible with data
analysis pipelines where the data format is fixed but the analyses are
either being updated, which may affect narrative components including
the result discussion and conclusion, or where the experiment is
different, which affects all narrative components If the narrative
components are not changing with the data being pushed through your
analysis pipeline, then you may be better off writing the R Markdown
code manually.## Installation
You can install the released version of listdown from
[CRAN](https://CRAN.R-project.org) with:``` r
install.packages("listdown")
```The development version of {listdown} can be installed from
[GitHub](https://github.com/) with:``` r
# install.packages("devtools")
devtools::install_github("kaneplusplus/listdown")
```## Example
As a toy example, suppose we would like to create an html document
plotting Anscombe’s quartet with each plot having it’s own section. To
construct the document, we will need to two objects. The first is a
presentation list, whose names indicate section (or subsection) titles
and whose elements are the objects to present. The second is a
`listdown` object, which describes how the object should be rendered in
the document.``` r
library(listdown)
library(ggplot2)data(anscombe)
# Create the ggplot objects to display.
pres_list <- list(
Linear = ggplot(anscombe, aes(x = x1, y = y1)) + geom_point() + theme_bw(),
`Non Linear` = ggplot(anscombe, aes(x = x2, y = y2)) + geom_point() + theme_bw(),
`Outlier Vertical`= ggplot(anscombe, aes(x = x3, y = y3)) + geom_point() + theme_bw(),
`Outlier Horizontal` = ggplot(anscombe, aes(x = x4, y = y4)) + geom_point() + theme_bw())# Save the pres_list object so that it can be used in the R Markdown document.
saveRDS(pres_list, "pres-list.rds")# Create a listdown object.
ld <- listdown(load_cc_expr = readRDS("pres-list.rds"), # The expression to load pres_list.
package = "ggplot2") # The packages needed to render plots.# Output an html document to a string.
doc <- c(
as.character(
ld_rmarkdown_header("Anscombe's Quartet",
author = "Francis Anscombe",
date = "1973")),
ld_make_chunks(ld))cat(paste(doc, collapse = "\n"))
```#> ---
#> title: Anscombe's Quartet
#> author: Francis Anscombe
#> date: '1973'
#> output: html_document
#> ---
#>
#> ```{r}
#> library(ggplot2)
#>
#> cc_list <- readRDS("pres-list.rds")
#> ```
#>
#> # Linear
#>
#> ```{r}
#> cc_list$Linear
#> ```
#>
#> # Non Linear
#>
#> ```{r}
#> cc_list$`Non Linear`
#> ```
#>
#> # Outlier Vertical
#>
#> ```{r}
#> cc_list$`Outlier Vertical`
#> ```
#>
#> # Outlier Horizontal
#>
#> ```{r}
#> cc_list$`Outlier Horizontal`
#> ```The document can then be written to a file, rendered, and viewed with
the following code.``` r
library(rmarkdown)writeLines(doc, file("anscombe.Rmd"))
render("anscombe.Rmd")
browseURL("anscombe.html")
```## Code of Conduct
Please note that the {listdown} project is released with a [Contributor
Code of Conduct](CODE_OF_CONDUCT.md). By contributing to this project,
you agree to abide by its terms.