diff --git a/.Rbuildignore b/.Rbuildignore index 0a9fe26..db68a9a 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -11,3 +11,4 @@ ^inst/JSS4145_prescreened$ ^inst/jss$ ^inst/r-medicine-2020$ +^\.github$ diff --git a/.github/.gitignore b/.github/.gitignore new file mode 100644 index 0000000..2d19fc7 --- /dev/null +++ b/.github/.gitignore @@ -0,0 +1 @@ +*.html diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml new file mode 100644 index 0000000..fb4fc50 --- /dev/null +++ b/.github/workflows/R-CMD-check.yaml @@ -0,0 +1,107 @@ +# NOTE: This workflow is overkill for most R packages +# check-standard.yaml is likely a better choice +# usethis::use_github_action("check-standard") will install it. +# +# For help debugging build failures open an issue on the RStudio community with the 'github-actions' tag. +# https://community.rstudio.com/new-topic?category=Package%20development&tags=github-actions +on: + push: + branches: + - main + - master + pull_request: + branches: + - main + - master + +name: R-CMD-check + +jobs: + R-CMD-check: + runs-on: ${{ matrix.config.os }} + + name: ${{ matrix.config.os }} (${{ matrix.config.r }}) + + strategy: + fail-fast: false + matrix: + config: + - {os: macOS-latest, r: 'release'} + - {os: windows-latest, r: 'release'} + - {os: windows-latest, r: '3.6'} + - {os: ubuntu-18.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest", http-user-agent: "R/4.0.0 (ubuntu-18.04) R (4.0.0 x86_64-pc-linux-gnu x86_64 linux-gnu) on GitHub Actions" } + - {os: ubuntu-18.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"} + - {os: ubuntu-18.04, r: 'oldrel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"} + - {os: ubuntu-18.04, r: '3.5', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"} + - {os: ubuntu-18.04, r: '3.4', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"} + - {os: ubuntu-18.04, r: '3.3', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"} + + env: + RSPM: ${{ matrix.config.rspm }} + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + + steps: + - uses: actions/checkout@v2 + + - uses: r-lib/actions/setup-r@v1 + id: install-r + with: + r-version: ${{ matrix.config.r }} + http-user-agent: ${{ matrix.config.http-user-agent }} + + - uses: r-lib/actions/setup-pandoc@v1 + + - name: Install pak and query dependencies + run: | + install.packages("pak", repos = "https://r-lib.github.io/p/pak/dev/") + saveRDS(pak::pkg_deps("local::.", dependencies = TRUE), ".github/r-depends.rds") + shell: Rscript {0} + + - name: Restore R package cache + uses: actions/cache@v2 + with: + path: | + ${{ env.R_LIBS_USER }}/* + !${{ env.R_LIBS_USER }}/pak + key: ${{ matrix.config.os }}-${{ steps.install-r.outputs.installed-r-version }}-1-${{ hashFiles('.github/r-depends.rds') }} + restore-keys: ${{ matrix.config.os }}-${{ steps.install-r.outputs.installed-r-version }}-1- + + - name: Install system dependencies + if: runner.os == 'Linux' + run: | + pak::local_system_requirements(execute = TRUE) + pak::pkg_system_requirements("rcmdcheck", execute = TRUE) + shell: Rscript {0} + + - name: Install dependencies + run: | + pak::local_install_dev_deps(upgrade = TRUE) + pak::pkg_install("rcmdcheck") + shell: Rscript {0} + + - name: Session info + run: | + options(width = 100) + pkgs <- installed.packages()[, "Package"] + sessioninfo::session_info(pkgs, include_base = TRUE) + shell: Rscript {0} + + - name: Check + env: + _R_CHECK_CRAN_INCOMING_: false + run: | + options(crayon.enabled = TRUE) + rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check") + shell: Rscript {0} + + - name: Show testthat output + if: always() + run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true + shell: bash + + - name: Upload check results + if: failure() + uses: actions/upload-artifact@main + with: + name: ${{ matrix.config.os }}-r${{ matrix.config.r }}-results + path: check diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4770f3d --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +inst/JSS4145_prescreened +inst/JSS4145_prescreened.zip +inst/r-medicine-2020 +inst/jss diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index eba8c65..0000000 --- a/.travis.yml +++ /dev/null @@ -1,4 +0,0 @@ -# R for travis: see documentation at https://docs.travis-ci.com/user/languages/r - -language: R -cache: packages diff --git a/R/build-site.r b/R/build-site.r index d7ab9a2..64ec313 100644 --- a/R/build-site.r +++ b/R/build-site.r @@ -345,10 +345,6 @@ ld_create_doc <- ) if (ldb$cc_in_memory) { - if (is.null(data_dir) && is.null(cc_file_name)) { - data_dir <- "../data" - cc_file_name <- basename(tempfile(pattern = "data", fileext = ".rds")) - } if (is.null(data_dir)) { data_dir <- "../data" warning("Argument `data_dir` is not specified, ../data will be used.") diff --git a/R/chunk-writer.r b/R/chunk-writer.r index 1148b5d..00c1e79 100644 --- a/R/chunk-writer.r +++ b/R/chunk-writer.r @@ -251,26 +251,26 @@ ld_make_chunks.listdown <- function(ld, rmd_dir = ".") { " from directory ", rmd_dir) }) - if (is.character(cc_list)) { - cc_list <- tryCatch( - { - setwd(rmd_dir) - ret <- eval(parse(text = cc_list)) - setwd(wd) - ret - }, - error = function(e) { - setwd(wd) - stop("Can't evaluate", ld$load_cc_expr, "from directory", rmd_dir) - }) - cc_list <- eval(parse(text = cc_list)) - } +# if (is.character(cc_list)) { +# cc_list <- tryCatch( +# { +# setwd(rmd_dir) +# ret <- eval(parse(text = cc_list)) +# setwd(wd) +# ret +# }, +# error = function(e) { +# setwd(wd) +# stop("Can't evaluate", ld$load_cc_expr, "from directory", rmd_dir) +# }) +# cc_list <- eval(parse(text = cc_list)) +# } - if (inherits(ld$load_cc_expr, "call")) { - cc_list <- expr_to_string(ld$load_cc_expr) - } else { - stop("The load_cc_expr element should be a call object.") - } +# if (inherits(ld$load_cc_expr, "call")) { +# cc_list <- expr_to_string(ld$load_cc_expr) +# } else { +# stop("The load_cc_expr element should be a call object.") +# } ret_string <- "" if (length(ld$setup_expr)) { ret_string <- c(ret_string, diff --git a/README.md b/README.md index 108a465..4225751 100644 --- a/README.md +++ b/README.md @@ -1,42 +1,52 @@ ---- -output: github_document ---- - - # listdown + [![](https://www.r-pkg.org/badges/version/listdown?color=blue)](https://cran.r-project.org/package=listdown) -[![Build Status](https://travis-ci.org/kaneplusplus/listdown.svg?branch=master)](https://travis-ci.org/kaneplusplus/listdown) -[![AppVeyor build status](https://ci.appveyor.com/api/projects/status/github/kaneplusplus/listdown?branch=master&svg=true)](https://ci.appveyor.com/project/kaneplusplus/listdown) -[![codecov](https://codecov.io/gh/kaneplusplus/listdown/branch/master/graph/badge.svg)](https://codecov.io/gh/kaneplusplus/listdown) -[![](http://cranlogs.r-pkg.org/badges/last-month/listdown?color=blue)](https://cran.r-project.org/package=listdown) -[![Travis build status](https://travis-ci.com/kaneplusplus/listdown.svg?branch=master)](https://travis-ci.com/kaneplusplus/listdown) +[![R-CMD-check](https://github.com/kaneplusplus/listdown/workflows/R-CMD-check/badge.svg)](https://github.com/kaneplusplus/listdown/actions) -## 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. +## 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: +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: +The development version of {listdown} can be installed from +[GitHub](https://github.com/) with: ``` r # install.packages("devtools") @@ -45,14 +55,15 @@ 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. +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 +``` r library(listdown) library(ggplot2) @@ -83,50 +94,47 @@ doc <- c( 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. -``` -#> --- -#> 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 +``` r library(rmarkdown) writeLines(doc, file("anscombe.Rmd")) @@ -134,8 +142,6 @@ render("anscombe.Rmd") browseURL("anscombe.html") ``` - - [![](https://www.r-pkg.org/badges/version/listdown?color=blue)](https://cran.r-project.org/package=listdown) -[![Build Status](https://travis-ci.org/kaneplusplus/listdown.svg?branch=master)](https://travis-ci.org/kaneplusplus/listdown) -[![AppVeyor build status](https://ci.appveyor.com/api/projects/status/github/kaneplusplus/listdown?branch=master&svg=true)](https://ci.appveyor.com/project/kaneplusplus/listdown) -[![codecov](https://codecov.io/gh/kaneplusplus/listdown/branch/master/graph/badge.svg)](https://codecov.io/gh/kaneplusplus/listdown) -[![](http://cranlogs.r-pkg.org/badges/last-month/listdown?color=blue)](https://cran.r-project.org/package=listdown) -[![Travis build status](https://travis-ci.com/kaneplusplus/listdown.svg?branch=master)](https://travis-ci.com/kaneplusplus/listdown) +[![R-CMD-check](https://github.com/kaneplusplus/listdown/workflows/R-CMD-check/badge.svg)](https://github.com/kaneplusplus/listdown/actions) ## Overview diff --git a/docs/404.html b/docs/404.html new file mode 100644 index 0000000..c9f059f --- /dev/null +++ b/docs/404.html @@ -0,0 +1,151 @@ + + + + + + + + +Page not found (404) • listdown + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +Content not found. Please use links in the navbar. + +
+ + + +
+ + + + +
+ + + + + + + + diff --git a/docs/CODE_OF_CONDUCT.html b/docs/CODE_OF_CONDUCT.html new file mode 100644 index 0000000..fb98a23 --- /dev/null +++ b/docs/CODE_OF_CONDUCT.html @@ -0,0 +1,159 @@ + + + + + + + + +Contributor Code of Conduct • listdown + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+ +

As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.

+

We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.

+

Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.

+

Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.

+

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.

+

This Code of Conduct is adapted from the Contributor Covenant (https://www.contributor-covenant.org), version 1.0.0, available at https://contributor-covenant.org/version/1/0/0/.

+
+ +
+ + + +
+ + + + +
+ + + + + + + + diff --git a/docs/LICENSE.html b/docs/LICENSE.html new file mode 100644 index 0000000..8e88d6e --- /dev/null +++ b/docs/LICENSE.html @@ -0,0 +1,242 @@ + + + + + + + + +Apache License • listdown + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+ +

Version 2.0, January 2004 <http://www.apache.org/licenses/>

+
+

+Terms and Conditions for use, reproduction, and distribution

+
+

+1. Definitions

+

“License” shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.

+

“Licensor” shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.

+

“Legal Entity” shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, “control” means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.

+

“You” (or “Your”) shall mean an individual or Legal Entity exercising permissions granted by this License.

+

“Source” form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.

+

“Object” form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.

+

“Work” shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).

+

“Derivative Works” shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.

+

“Contribution” shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, “submitted” means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as “Not a Contribution.”

+

“Contributor” shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.

+
+ +
+

+3. Grant of Patent License

+

Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.

+
+
+

+4. Redistribution

+

You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:

+
    +
  • +(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
  • +
  • +(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
  • +
  • +(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
  • +
  • +(d) If the Work includes a “NOTICE” text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
  • +
+

You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.

+
+
+

+5. Submission of Contributions

+

Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.

+
+
+

+6. Trademarks

+

This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.

+
+
+

+7. Disclaimer of Warranty

+

Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.

+
+
+

+8. Limitation of Liability

+

In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.

+
+
+

+9. Accepting Warranty or Additional Liability

+

While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.

+

END OF TERMS AND CONDITIONS

+
+
+
+

+APPENDIX: How to apply the Apache License to your work

+

To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets [] replaced with your own identifying information. (Don’t include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same “printed page” as the copyright notice for easier identification within third-party archives.

+
Copyright 2020 listdown
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+
+ +
+ + + +
+ + + + +
+ + + + + + + + diff --git a/docs/articles/index.html b/docs/articles/index.html new file mode 100644 index 0000000..2df10df --- /dev/null +++ b/docs/articles/index.html @@ -0,0 +1,150 @@ + + + + + + + + +Articles • listdown + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

All vignettes

+

+ +
+
The listdown Package
+
+
+
+
+
+ + + +
+ + + + + + + + diff --git a/docs/articles/listdown.html b/docs/articles/listdown.html new file mode 100644 index 0000000..4d11550 --- /dev/null +++ b/docs/articles/listdown.html @@ -0,0 +1,345 @@ + + + + + + + +The listdown Package • listdown + + + + + + + + + + +
+
+ + + + +
+
+ + + + +
+

+Background and Concepts

+

R Markdown documents support the construction of reproducible documents by allowing authors to insert R code for data processing, exploration, analysis, table-making, and visualization directly into structured, prose documents. In the context of this document, we will refer to the R code in these documents as computational components since they are generated by computational means (namely the R interpreter). The prose in these documents will be referred to as narrative components. They may serve to help a reader understand the background, goal, theme, and results of the paper as well as contextualizing the computational components.

+

R Markdown integrates the process of integrating the computational and narrative components of a document. By itself this is not novel. It was identified as “Literate Programming” in and software tools, like Sweave have supported this functionality for over a decade. R Markdown’s popularity has likely been driven by two factors. The first is the relative ease with which these documents can be constructed. While it is more expressive, is relatively technical and requires an investment in time to become proficient. By contrast R Markdown documents are easier to create and format and, when the document is used to create formatting can be passed through to the underlying .tex file. The second factor driving adoption is likely its support for creating modifiable documents, Microsoft Word in particular. Researchers and analysts, especially those creating applied statistical analyses, often collaborate with domain experts with less technical knowledge. In these cases, the analyst focuses on creating the computational components and narrative components related to results and interpretation. After this initial document is created, the domain expert is free to develop narrative components directly in the document without needing to go through the analyst.

+

Since computational components are, by definition, computationally derived objects and R Markdown is a well-defined standard it is possible to programmatically create R Markdown documents with computational components. This is the focus of this paper. However, before proceeding down this avenue, we would like to highlight two fundamental limitations to automated R Markdown document construction. First and foremost, without narrative components a document has no context. Quantitative analyses require research questions, hypotheses, reviews, interpretations, and conclusions. Computational components are necessary but not sufficient for constructing an analysis. Second, it is not possible to construct computational components for an arbitrary set of distinct analyses. An analysis itself has a context and it is built with a set of assumptions and goals. Computational components are constructed for a narrow class of problems.

+

However, this is not to say the programmatic creation of R Markdown documents is unwarranted or not useful. In fact it has at least two appealing characteristics. The first is convenience. The second is that for fixed analysis pipelines processing uniformly-formatted but domain-distinct data, automated document generation enforces uniformity across those domains being serviced.

+

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.

+

The package itself is relatively simple with 6 distinct methods that can be easily incorporated into existing analysis pipelines for automatically creating documents that can be used for data exploration and reviewing analysis results as well as a starting point for a more formal write up. These methods include:

+

listdown() - Create a listdown object to create an R Markdown document. ld_make_chunks() - Write a listdown object to a string. ld_chunk_opts() - Apply chunk options to a presentation object. ld_workflowr_header() - Create a workflowr header. ld_rmarkdown_header() - Create an R Markdown header. ld_ioslides_header() - Create an ioslides presentation header.

+

The rest of this paper is structured as follow. The next section goes over basic usage and commentary. This section is meant to convey the basic approach used by the package and shows how to describe an output document using listdown, create a document, and change how the presentation of computational components can be specialized using listdown decorators. With the user accustomed to the package’s basic usage, section 3 describes the design of the package. Section 4 goes over advanced usage of the package including adding initialization code to and outputted document as well as how to control chunk-level options. Section 5 concludes the paper with a few final remarks.

+
+
+

+Basic Usage and Commentary

+

Suppose we have just completed and analysis and have collected all of the results into a list where the list elements are roughly in the order we would like to present them in a document. It may be noted that this is not always how computational components derived from data analyses are collated. Often individual components are stored in multiple locations on a single machine or across machines. However, it is important to realize that even for analyses on large-scale data, the digital artifact that will be presented will be relatively small. Centralizing them makes it easier to access them, since they don’t need to be found in multiple locations. Also, storing them as a list provides a hierarchical structure that translates directly to a document as we will see below.

+

As a first example, we will consider the a list of visualizations from the anscombe data set. The list is composed of four elements (named Linear, Non Linear, Outlier Vertical, and Outlier Horizontal) each containing a scatter plot from the famous Anscomb Quartet. From the computational_components list, we would like to create a document with four sections with names corresponding to the list names, each containing their respective visualizations.

+
+# Use ggplot2 to create the visualizations.
+library(ggplot2)
+
+# Load the Anscombe Quartet.
+data(anscombe)
+
+# Create the ggplot objects to display.
+computational_components <- 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 file to disk to be read by the output R Markdown document.
+saveRDS(computational_components, "comp-comp.rds")
+
+

+Creating a Document with listdown

+

Creating a document from the computational_components will require two steps. First, we will create a listdown object that specifies how the computational_components object will be loaded into the document, which libraries and code needs to be included, the options for the R chunks, and how the list elements will be presented in the output R markdown document.

+
+library(listdown)
+
+ld <- listdown(load_cc_expr = readRDS("comp-comp.rds"),
+               package = "ggplot2")
+

The ld object, along with the computational components in the comp-comp.rds file are sufficient to to create the sections, subsections, and R chunks of a document. The only other thing requires to create the document is the header. The listdown package currently supports regular R Markdown, workflowr, and ioslides headers. A complete document can then be written to the console using the code shown below. It could easily be written to a file for rendering using the writeLines() function, for example.

+
+doc <- c(
+  as.character(ld_rmarkdown_header("Anscombe's Quartet",
+                                   author = "Francis Anscombe",
+                                   date = "1973")),
+  ld_make_chunks(ld))
+
+cat("\n", paste(doc, collapse = "\n"))
+#> 
+#>  ---
+#> title: Anscombe's Quartet
+#> author: Francis Anscombe
+#> date: '1973'
+#> output: html_document
+#> ---
+#> 
+#> ```{r}
+#> library(ggplot2)
+#> 
+#> cc_list <- readRDS("comp-comp.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`
+#> ```
+#> 
+#> # Data
+#> 
+#> ```{r}
+#> cc_list$Data
+#> ```
+

The listdown() function provides document-wide R chunk options for displaying computational components. The chunk options are exactly the same as those in the R markdown document and can be used to tailor the default presentation for a variety of needs. The complete set of options can be found in the R Markdown Reference Guide. As a concrete example, the code used to create present the plots could be hidden in the output document using the following code.

+
+ld <- listdown(load_cc_expr = readRDS("comp-comp.rds"), 
+               package = "ggplot2",
+               echo = FALSE)
+
+cat(paste(ld_make_chunks(ld), collapse = "\n"))
+#> 
+#> ```{r echo = FALSE}
+#> library(ggplot2)
+#> 
+#> cc_list <- readRDS("comp-comp.rds")
+#> ```
+#> 
+#> # Linear
+#> 
+#> ```{r echo = FALSE}
+#> cc_list$Linear
+#> ```
+#> 
+#> # Non Linear
+#> 
+#> ```{r echo = FALSE}
+#> cc_list$`Non Linear`
+#> ```
+#> 
+#> # Outlier Vertical
+#> 
+#> ```{r echo = FALSE}
+#> cc_list$`Outlier Vertical`
+#> ```
+#> 
+#> # Outlier Horizontal
+#> 
+#> ```{r echo = FALSE}
+#> cc_list$`Outlier Horizontal`
+#> ```
+#> 
+#> # Data
+#> 
+#> ```{r echo = FALSE}
+#> cc_list$Data
+#> ```
+
+
+

+Decorators

+

The first example is simple in part because the ggplot objects both contain the data we want to display and, at the same time, provide the mechanism for presenting them - rendering them in a graph. However, this is not always the case. The objects being stored in the list of computational components may not translate directly to the presentation in a document. In these cases a function is needed that takes the list component and returns an object to be displayed. For example, suppose that, along with showing graphs from the Anscombe Quartet, we would like to include the data themselves. We could add the data to the computational_components list and then create the document with:

+
#> 
+#> ```{r echo = FALSE}
+#> library(ggplot2)
+#> 
+#> cc_list <- readRDS("comp-comp.rds")
+#> ```
+#> 
+#> # Linear
+#> 
+#> ```{r echo = FALSE}
+#> cc_list$Linear
+#> ```
+#> 
+#> # Non Linear
+#> 
+#> ```{r echo = FALSE}
+#> cc_list$`Non Linear`
+#> ```
+#> 
+#> # Outlier Vertical
+#> 
+#> ```{r echo = FALSE}
+#> cc_list$`Outlier Vertical`
+#> ```
+#> 
+#> # Outlier Horizontal
+#> 
+#> ```{r echo = FALSE}
+#> cc_list$`Outlier Horizontal`
+#> ```
+#> 
+#> # Data
+#> 
+#> ```{r echo = FALSE}
+#> cc_list$Data
+#> ```
+
+computational_components$Data <- anscombe
+saveRDS(computational_components, "comp-comp.rds")
+cat(paste(ld_make_chunks(ld), collapse = "\n"))
+

In this case, the {listdown} package will show the entire data set as is the default specified. However, suppose we do not want to show the entire data set in the document. This is common, especially when the data set is large and requires too much vertical space in the outputted document resulting in too much or irrelevant data being shown. Instead, we would like to output to an html document where the data is shown in a datatable thereby controlling the amount of real-estate needed to present the data and, at the same time, providing the user with interactivity to sort and search the data set.

+

In {listdown} a function or method that implements the presentation of a computational component is referred to as a {} since if follows the decorator pattern described in the classic software engineering text “Design Patterns” by Gamma et al. A decorator takes the element that will be presented as an argument and returns an object for presentation in the output directory. A decorator is specified using the decorator parameter of the listdown() function using a named list where the name corresponds to the type and the element correspond to the function or method that will decorate an object of that type. For example, the anscombe data set can be decorated with the DT::datatable() function as follow. It should be noted that the DT library both loaded in the following code and specified as a package options. This allows ld_make_chunks() to verify the existence of decorators before generating the chunks.

+
+library(DT)
+ld <- listdown(load_cc_expr = readRDS("comp-comp.rds"), 
+               package = c("ggplot2", "DT"),
+               decorator = list(data.frame = datatable))
+cat(paste(ld_make_chunks(ld), collapse = "\n"))
+#> 
+#> ```{r}
+#> library(ggplot2)
+#> library(DT)
+#> 
+#> cc_list <- readRDS("comp-comp.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`
+#> ```
+#> 
+#> # Data
+#> 
+#> ```{r}
+#> datatable(cc_list$Data)
+#> ```
+

List names in the decorator argument provide a key to which a function or method is mapped. The underlying decorator resolution is implemented for a given computational component by going through decorator names sequentially to see if the component inherits from the name using the inherits() function. The function or method is selected from the corresponding name which the element first inherits from. This means that when customizing the presentation of objects that inherit from a common class, the more abstract classes should appear at the end of the list. This will ensure that specialized classes will be encountered first in the resolution process.

+

A separate argument, default_decorator, allows the user to specify the default decorator for an object whose type does not appear in the decorator list. This allows the user to specify any class name for the decorator and avoids a potential type name collision with a default decorator whose name is determined by convention. By default, this argument is set to identity but it can be use to not display a computational component by default if the argument is set to NULL.

+
+
+
+ + + +
+ + + + +
+ + + + + + diff --git a/docs/articles/listdown_files/header-attrs-2.7/header-attrs.js b/docs/articles/listdown_files/header-attrs-2.7/header-attrs.js new file mode 100644 index 0000000..dd57d92 --- /dev/null +++ b/docs/articles/listdown_files/header-attrs-2.7/header-attrs.js @@ -0,0 +1,12 @@ +// Pandoc 2.9 adds attributes on both header and div. We remove the former (to +// be compatible with the behavior of Pandoc < 2.8). +document.addEventListener('DOMContentLoaded', function(e) { + var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); + var i, h, a; + for (i = 0; i < hs.length; i++) { + h = hs[i]; + if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 + a = h.attributes; + while (a.length > 0) h.removeAttribute(a[0].name); + } +}); diff --git a/docs/authors.html b/docs/authors.html new file mode 100644 index 0000000..e8e4d90 --- /dev/null +++ b/docs/authors.html @@ -0,0 +1,150 @@ + + + + + + + + +Authors • listdown + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
    +
  • +

    Michael J. Kane. Author, copyright holder, maintainer. +

    +
  • +
+ +
+ +
+ + + + +
+ + + + + + + + diff --git a/docs/bootstrap-toc.css b/docs/bootstrap-toc.css new file mode 100644 index 0000000..5a85941 --- /dev/null +++ b/docs/bootstrap-toc.css @@ -0,0 +1,60 @@ +/*! + * Bootstrap Table of Contents v0.4.1 (http://afeld.github.io/bootstrap-toc/) + * Copyright 2015 Aidan Feldman + * Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */ + +/* modified from https://github.com/twbs/bootstrap/blob/94b4076dd2efba9af71f0b18d4ee4b163aa9e0dd/docs/assets/css/src/docs.css#L548-L601 */ + +/* All levels of nav */ +nav[data-toggle='toc'] .nav > li > a { + display: block; + padding: 4px 20px; + font-size: 13px; + font-weight: 500; + color: #767676; +} +nav[data-toggle='toc'] .nav > li > a:hover, +nav[data-toggle='toc'] .nav > li > a:focus { + padding-left: 19px; + color: #563d7c; + text-decoration: none; + background-color: transparent; + border-left: 1px solid #563d7c; +} +nav[data-toggle='toc'] .nav > .active > a, +nav[data-toggle='toc'] .nav > .active:hover > a, +nav[data-toggle='toc'] .nav > .active:focus > a { + padding-left: 18px; + font-weight: bold; + color: #563d7c; + background-color: transparent; + border-left: 2px solid #563d7c; +} + +/* Nav: second level (shown on .active) */ +nav[data-toggle='toc'] .nav .nav { + display: none; /* Hide by default, but at >768px, show it */ + padding-bottom: 10px; +} +nav[data-toggle='toc'] .nav .nav > li > a { + padding-top: 1px; + padding-bottom: 1px; + padding-left: 30px; + font-size: 12px; + font-weight: normal; +} +nav[data-toggle='toc'] .nav .nav > li > a:hover, +nav[data-toggle='toc'] .nav .nav > li > a:focus { + padding-left: 29px; +} +nav[data-toggle='toc'] .nav .nav > .active > a, +nav[data-toggle='toc'] .nav .nav > .active:hover > a, +nav[data-toggle='toc'] .nav .nav > .active:focus > a { + padding-left: 28px; + font-weight: 500; +} + +/* from https://github.com/twbs/bootstrap/blob/e38f066d8c203c3e032da0ff23cd2d6098ee2dd6/docs/assets/css/src/docs.css#L631-L634 */ +nav[data-toggle='toc'] .nav > .active > ul { + display: block; +} diff --git a/docs/bootstrap-toc.js b/docs/bootstrap-toc.js new file mode 100644 index 0000000..1cdd573 --- /dev/null +++ b/docs/bootstrap-toc.js @@ -0,0 +1,159 @@ +/*! + * Bootstrap Table of Contents v0.4.1 (http://afeld.github.io/bootstrap-toc/) + * Copyright 2015 Aidan Feldman + * Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */ +(function() { + 'use strict'; + + window.Toc = { + helpers: { + // return all matching elements in the set, or their descendants + findOrFilter: function($el, selector) { + // http://danielnouri.org/notes/2011/03/14/a-jquery-find-that-also-finds-the-root-element/ + // http://stackoverflow.com/a/12731439/358804 + var $descendants = $el.find(selector); + return $el.filter(selector).add($descendants).filter(':not([data-toc-skip])'); + }, + + generateUniqueIdBase: function(el) { + var text = $(el).text(); + var anchor = text.trim().toLowerCase().replace(/[^A-Za-z0-9]+/g, '-'); + return anchor || el.tagName.toLowerCase(); + }, + + generateUniqueId: function(el) { + var anchorBase = this.generateUniqueIdBase(el); + for (var i = 0; ; i++) { + var anchor = anchorBase; + if (i > 0) { + // add suffix + anchor += '-' + i; + } + // check if ID already exists + if (!document.getElementById(anchor)) { + return anchor; + } + } + }, + + generateAnchor: function(el) { + if (el.id) { + return el.id; + } else { + var anchor = this.generateUniqueId(el); + el.id = anchor; + return anchor; + } + }, + + createNavList: function() { + return $(''); + }, + + createChildNavList: function($parent) { + var $childList = this.createNavList(); + $parent.append($childList); + return $childList; + }, + + generateNavEl: function(anchor, text) { + var $a = $(''); + $a.attr('href', '#' + anchor); + $a.text(text); + var $li = $('
  • '); + $li.append($a); + return $li; + }, + + generateNavItem: function(headingEl) { + var anchor = this.generateAnchor(headingEl); + var $heading = $(headingEl); + var text = $heading.data('toc-text') || $heading.text(); + return this.generateNavEl(anchor, text); + }, + + // Find the first heading level (`

    `, then `

    `, etc.) that has more than one element. Defaults to 1 (for `

    `). + getTopLevel: function($scope) { + for (var i = 1; i <= 6; i++) { + var $headings = this.findOrFilter($scope, 'h' + i); + if ($headings.length > 1) { + return i; + } + } + + return 1; + }, + + // returns the elements for the top level, and the next below it + getHeadings: function($scope, topLevel) { + var topSelector = 'h' + topLevel; + + var secondaryLevel = topLevel + 1; + var secondarySelector = 'h' + secondaryLevel; + + return this.findOrFilter($scope, topSelector + ',' + secondarySelector); + }, + + getNavLevel: function(el) { + return parseInt(el.tagName.charAt(1), 10); + }, + + populateNav: function($topContext, topLevel, $headings) { + var $context = $topContext; + var $prevNav; + + var helpers = this; + $headings.each(function(i, el) { + var $newNav = helpers.generateNavItem(el); + var navLevel = helpers.getNavLevel(el); + + // determine the proper $context + if (navLevel === topLevel) { + // use top level + $context = $topContext; + } else if ($prevNav && $context === $topContext) { + // create a new level of the tree and switch to it + $context = helpers.createChildNavList($prevNav); + } // else use the current $context + + $context.append($newNav); + + $prevNav = $newNav; + }); + }, + + parseOps: function(arg) { + var opts; + if (arg.jquery) { + opts = { + $nav: arg + }; + } else { + opts = arg; + } + opts.$scope = opts.$scope || $(document.body); + return opts; + } + }, + + // accepts a jQuery object, or an options object + init: function(opts) { + opts = this.helpers.parseOps(opts); + + // ensure that the data attribute is in place for styling + opts.$nav.attr('data-toggle', 'toc'); + + var $topContext = this.helpers.createChildNavList(opts.$nav); + var topLevel = this.helpers.getTopLevel(opts.$scope); + var $headings = this.helpers.getHeadings(opts.$scope, topLevel); + this.helpers.populateNav($topContext, topLevel, $headings); + } + }; + + $(function() { + $('nav[data-toggle="toc"]').each(function(i, el) { + var $nav = $(el); + Toc.init($nav); + }); + }); +})(); diff --git a/docs/docsearch.css b/docs/docsearch.css new file mode 100644 index 0000000..e5f1fe1 --- /dev/null +++ b/docs/docsearch.css @@ -0,0 +1,148 @@ +/* Docsearch -------------------------------------------------------------- */ +/* + Source: https://github.com/algolia/docsearch/ + License: MIT +*/ + +.algolia-autocomplete { + display: block; + -webkit-box-flex: 1; + -ms-flex: 1; + flex: 1 +} + +.algolia-autocomplete .ds-dropdown-menu { + width: 100%; + min-width: none; + max-width: none; + padding: .75rem 0; + background-color: #fff; + background-clip: padding-box; + border: 1px solid rgba(0, 0, 0, .1); + box-shadow: 0 .5rem 1rem rgba(0, 0, 0, .175); +} + +@media (min-width:768px) { + .algolia-autocomplete .ds-dropdown-menu { + width: 175% + } +} + +.algolia-autocomplete .ds-dropdown-menu::before { + display: none +} + +.algolia-autocomplete .ds-dropdown-menu [class^=ds-dataset-] { + padding: 0; + background-color: rgb(255,255,255); + border: 0; + max-height: 80vh; +} + +.algolia-autocomplete .ds-dropdown-menu .ds-suggestions { + margin-top: 0 +} + +.algolia-autocomplete .algolia-docsearch-suggestion { + padding: 0; + overflow: visible +} + +.algolia-autocomplete .algolia-docsearch-suggestion--category-header { + padding: .125rem 1rem; + margin-top: 0; + font-size: 1.3em; + font-weight: 500; + color: #00008B; + border-bottom: 0 +} + +.algolia-autocomplete .algolia-docsearch-suggestion--wrapper { + float: none; + padding-top: 0 +} + +.algolia-autocomplete .algolia-docsearch-suggestion--subcategory-column { + float: none; + width: auto; + padding: 0; + text-align: left +} + +.algolia-autocomplete .algolia-docsearch-suggestion--content { + float: none; + width: auto; + padding: 0 +} + +.algolia-autocomplete .algolia-docsearch-suggestion--content::before { + display: none +} + +.algolia-autocomplete .ds-suggestion:not(:first-child) .algolia-docsearch-suggestion--category-header { + padding-top: .75rem; + margin-top: .75rem; + border-top: 1px solid rgba(0, 0, 0, .1) +} + +.algolia-autocomplete .ds-suggestion .algolia-docsearch-suggestion--subcategory-column { + display: block; + padding: .1rem 1rem; + margin-bottom: 0.1; + font-size: 1.0em; + font-weight: 400 + /* display: none */ +} + +.algolia-autocomplete .algolia-docsearch-suggestion--title { + display: block; + padding: .25rem 1rem; + margin-bottom: 0; + font-size: 0.9em; + font-weight: 400 +} + +.algolia-autocomplete .algolia-docsearch-suggestion--text { + padding: 0 1rem .5rem; + margin-top: -.25rem; + font-size: 0.8em; + font-weight: 400; + line-height: 1.25 +} + +.algolia-autocomplete .algolia-docsearch-footer { + width: 110px; + height: 20px; + z-index: 3; + margin-top: 10.66667px; + float: right; + font-size: 0; + line-height: 0; +} + +.algolia-autocomplete .algolia-docsearch-footer--logo { + background-image: url("data:image/svg+xml;utf8,"); + background-repeat: no-repeat; + background-position: 50%; + background-size: 100%; + overflow: hidden; + text-indent: -9000px; + width: 100%; + height: 100%; + display: block; + transform: translate(-8px); +} + +.algolia-autocomplete .algolia-docsearch-suggestion--highlight { + color: #FF8C00; + background: rgba(232, 189, 54, 0.1) +} + + +.algolia-autocomplete .algolia-docsearch-suggestion--text .algolia-docsearch-suggestion--highlight { + box-shadow: inset 0 -2px 0 0 rgba(105, 105, 105, .5) +} + +.algolia-autocomplete .ds-suggestion.ds-cursor .algolia-docsearch-suggestion--content { + background-color: rgba(192, 192, 192, .15) +} diff --git a/docs/docsearch.js b/docs/docsearch.js new file mode 100644 index 0000000..b35504c --- /dev/null +++ b/docs/docsearch.js @@ -0,0 +1,85 @@ +$(function() { + + // register a handler to move the focus to the search bar + // upon pressing shift + "/" (i.e. "?") + $(document).on('keydown', function(e) { + if (e.shiftKey && e.keyCode == 191) { + e.preventDefault(); + $("#search-input").focus(); + } + }); + + $(document).ready(function() { + // do keyword highlighting + /* modified from https://jsfiddle.net/julmot/bL6bb5oo/ */ + var mark = function() { + + var referrer = document.URL ; + var paramKey = "q" ; + + if (referrer.indexOf("?") !== -1) { + var qs = referrer.substr(referrer.indexOf('?') + 1); + var qs_noanchor = qs.split('#')[0]; + var qsa = qs_noanchor.split('&'); + var keyword = ""; + + for (var i = 0; i < qsa.length; i++) { + var currentParam = qsa[i].split('='); + + if (currentParam.length !== 2) { + continue; + } + + if (currentParam[0] == paramKey) { + keyword = decodeURIComponent(currentParam[1].replace(/\+/g, "%20")); + } + } + + if (keyword !== "") { + $(".contents").unmark({ + done: function() { + $(".contents").mark(keyword); + } + }); + } + } + }; + + mark(); + }); +}); + +/* Search term highlighting ------------------------------*/ + +function matchedWords(hit) { + var words = []; + + var hierarchy = hit._highlightResult.hierarchy; + // loop to fetch from lvl0, lvl1, etc. + for (var idx in hierarchy) { + words = words.concat(hierarchy[idx].matchedWords); + } + + var content = hit._highlightResult.content; + if (content) { + words = words.concat(content.matchedWords); + } + + // return unique words + var words_uniq = [...new Set(words)]; + return words_uniq; +} + +function updateHitURL(hit) { + + var words = matchedWords(hit); + var url = ""; + + if (hit.anchor) { + url = hit.url_without_anchor + '?q=' + escape(words.join(" ")) + '#' + hit.anchor; + } else { + url = hit.url + '?q=' + escape(words.join(" ")); + } + + return url; +} diff --git a/docs/index.html b/docs/index.html new file mode 100644 index 0000000..3612a33 --- /dev/null +++ b/docs/index.html @@ -0,0 +1,250 @@ + + + + + + + +Create R Markdown from Lists • listdown + + + + + + + + + + +
    +
    + + + + +
    +
    +
    + + + +
    +

    +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 with:

    +
    +install.packages("listdown")
    +

    The development version of {listdown} can be installed from GitHub with:

    +
    +# 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.

    +
    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 packges 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.

    +
    +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. By contributing to this project, you agree to abide by its terms.

    +
    +
    +
    + + +
    + + +
    + +
    +

    Site built with pkgdown 1.6.1.

    +
    + +
    +
    + + + + + + diff --git a/docs/link.svg b/docs/link.svg new file mode 100644 index 0000000..88ad827 --- /dev/null +++ b/docs/link.svg @@ -0,0 +1,12 @@ + + + + + + diff --git a/docs/news/index.html b/docs/news/index.html new file mode 100644 index 0000000..562ea26 --- /dev/null +++ b/docs/news/index.html @@ -0,0 +1,248 @@ + + + + + + + + +Changelog • listdown + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    +listdown 0.2.8 Unreleased +

    +
      +
    • Inital release to CRAN.
    • +
    +
    +
    +

    +listdown 0.2.9 Unreleased +

    +
      +
    • Minor updates for JSS submission based on comments.
    • +
    +
    +
    +

    +listdown 0.2.10 Unreleased +

    +
      +
    • Added CODE_OF_CONDUCT.md to .Rbuildignore
    • +
    +
    +
    +

    +listdown 0.2.11 Unreleased +

    +
      +
    • Removed the package name from the description title.
    • +
    +
    +
    +

    +listdown 0.2.12 Unreleased +

    +
      +
    • Title was put into title case.
    • +
    +
    +
    +

    +listdown 0.2.13 Unreleased +

    +
      +
    • dontrun was turned into donttest per CRAN feedback.
    • +
    +
    +
    +

    +listdown 0.2.15 Unreleased +

    +
      +
    • donttest was turned into dontrun per CRAN feedback.
    • +
    • vignette no longer writes files.
    • +
    • listdown() function can take a string literal for read expression.
    • +
    +
    +
    +

    +listdown 0.2.16 Unreleased +

    +
      +
    • Example fiddling for CRAN.
    • +
    +
    +
    +

    +listdown 0.2.17 Unreleased +

    +
      +
    • Gave up on ld_write_file.
    • +
    +
    +
    +

    +listdown 0.2.18 2020-07-04 +

    +
      +
    • Added rmarkdown Suggestion back.
    • +
    +
    +
    +

    +listdown 0.2.21 2020-07-27 +

    +
      +
    • Fixed a bug related to unnamed computational component lists elements.
    • +
    +
    +
    +

    +listdown 0.4.0 2020-12-06 +

    +
      +
    • Mulitple bug fixes.
    • +
    • The listdown() function now supports a setup_expr which, if specified is placed in a setup block.
    • +
    +
    +
    + + + +
    + + +
    + + +
    +

    Site built with pkgdown 1.6.1.

    +
    + +
    +
    + + + + + + + + diff --git a/docs/pkgdown.css b/docs/pkgdown.css new file mode 100644 index 0000000..1273238 --- /dev/null +++ b/docs/pkgdown.css @@ -0,0 +1,367 @@ +/* Sticky footer */ + +/** + * Basic idea: https://philipwalton.github.io/solved-by-flexbox/demos/sticky-footer/ + * Details: https://github.com/philipwalton/solved-by-flexbox/blob/master/assets/css/components/site.css + * + * .Site -> body > .container + * .Site-content -> body > .container .row + * .footer -> footer + * + * Key idea seems to be to ensure that .container and __all its parents__ + * have height set to 100% + * + */ + +html, body { + height: 100%; +} + +body { + position: relative; +} + +body > .container { + display: flex; + height: 100%; + flex-direction: column; +} + +body > .container .row { + flex: 1 0 auto; +} + +footer { + margin-top: 45px; + padding: 35px 0 36px; + border-top: 1px solid #e5e5e5; + color: #666; + display: flex; + flex-shrink: 0; +} +footer p { + margin-bottom: 0; +} +footer div { + flex: 1; +} +footer .pkgdown { + text-align: right; +} +footer p { + margin-bottom: 0; +} + +img.icon { + float: right; +} + +img { + max-width: 100%; +} + +/* Fix bug in bootstrap (only seen in firefox) */ +summary { + display: list-item; +} + +/* Typographic tweaking ---------------------------------*/ + +.contents .page-header { + margin-top: calc(-60px + 1em); +} + +dd { + margin-left: 3em; +} + +/* Section anchors ---------------------------------*/ + +a.anchor { + margin-left: -30px; + display:inline-block; + width: 30px; + height: 30px; + visibility: hidden; + + background-image: url(./link.svg); + background-repeat: no-repeat; + background-size: 20px 20px; + background-position: center center; +} + +.hasAnchor:hover a.anchor { + visibility: visible; +} + +@media (max-width: 767px) { + .hasAnchor:hover a.anchor { + visibility: hidden; + } +} + + +/* Fixes for fixed navbar --------------------------*/ + +.contents h1, .contents h2, .contents h3, .contents h4 { + padding-top: 60px; + margin-top: -40px; +} + +/* Navbar submenu --------------------------*/ + +.dropdown-submenu { + position: relative; +} + +.dropdown-submenu>.dropdown-menu { + top: 0; + left: 100%; + margin-top: -6px; + margin-left: -1px; + border-radius: 0 6px 6px 6px; +} + +.dropdown-submenu:hover>.dropdown-menu { + display: block; +} + +.dropdown-submenu>a:after { + display: block; + content: " "; + float: right; + width: 0; + height: 0; + border-color: transparent; + border-style: solid; + border-width: 5px 0 5px 5px; + border-left-color: #cccccc; + margin-top: 5px; + margin-right: -10px; +} + +.dropdown-submenu:hover>a:after { + border-left-color: #ffffff; +} + +.dropdown-submenu.pull-left { + float: none; +} + +.dropdown-submenu.pull-left>.dropdown-menu { + left: -100%; + margin-left: 10px; + border-radius: 6px 0 6px 6px; +} + +/* Sidebar --------------------------*/ + +#pkgdown-sidebar { + margin-top: 30px; + position: -webkit-sticky; + position: sticky; + top: 70px; +} + +#pkgdown-sidebar h2 { + font-size: 1.5em; + margin-top: 1em; +} + +#pkgdown-sidebar h2:first-child { + margin-top: 0; +} + +#pkgdown-sidebar .list-unstyled li { + margin-bottom: 0.5em; +} + +/* bootstrap-toc tweaks ------------------------------------------------------*/ + +/* All levels of nav */ + +nav[data-toggle='toc'] .nav > li > a { + padding: 4px 20px 4px 6px; + font-size: 1.5rem; + font-weight: 400; + color: inherit; +} + +nav[data-toggle='toc'] .nav > li > a:hover, +nav[data-toggle='toc'] .nav > li > a:focus { + padding-left: 5px; + color: inherit; + border-left: 1px solid #878787; +} + +nav[data-toggle='toc'] .nav > .active > a, +nav[data-toggle='toc'] .nav > .active:hover > a, +nav[data-toggle='toc'] .nav > .active:focus > a { + padding-left: 5px; + font-size: 1.5rem; + font-weight: 400; + color: inherit; + border-left: 2px solid #878787; +} + +/* Nav: second level (shown on .active) */ + +nav[data-toggle='toc'] .nav .nav { + display: none; /* Hide by default, but at >768px, show it */ + padding-bottom: 10px; +} + +nav[data-toggle='toc'] .nav .nav > li > a { + padding-left: 16px; + font-size: 1.35rem; +} + +nav[data-toggle='toc'] .nav .nav > li > a:hover, +nav[data-toggle='toc'] .nav .nav > li > a:focus { + padding-left: 15px; +} + +nav[data-toggle='toc'] .nav .nav > .active > a, +nav[data-toggle='toc'] .nav .nav > .active:hover > a, +nav[data-toggle='toc'] .nav .nav > .active:focus > a { + padding-left: 15px; + font-weight: 500; + font-size: 1.35rem; +} + +/* orcid ------------------------------------------------------------------- */ + +.orcid { + font-size: 16px; + color: #A6CE39; + /* margins are required by official ORCID trademark and display guidelines */ + margin-left:4px; + margin-right:4px; + vertical-align: middle; +} + +/* Reference index & topics ----------------------------------------------- */ + +.ref-index th {font-weight: normal;} + +.ref-index td {vertical-align: top; min-width: 100px} +.ref-index .icon {width: 40px;} +.ref-index .alias {width: 40%;} +.ref-index-icons .alias {width: calc(40% - 40px);} +.ref-index .title {width: 60%;} + +.ref-arguments th {text-align: right; padding-right: 10px;} +.ref-arguments th, .ref-arguments td {vertical-align: top; min-width: 100px} +.ref-arguments .name {width: 20%;} +.ref-arguments .desc {width: 80%;} + +/* Nice scrolling for wide elements --------------------------------------- */ + +table { + display: block; + overflow: auto; +} + +/* Syntax highlighting ---------------------------------------------------- */ + +pre { + word-wrap: normal; + word-break: normal; + border: 1px solid #eee; +} + +pre, code { + background-color: #f8f8f8; + color: #333; +} + +pre code { + overflow: auto; + word-wrap: normal; + white-space: pre; +} + +pre .img { + margin: 5px 0; +} + +pre .img img { + background-color: #fff; + display: block; + height: auto; +} + +code a, pre a { + color: #375f84; +} + +a.sourceLine:hover { + text-decoration: none; +} + +.fl {color: #1514b5;} +.fu {color: #000000;} /* function */ +.ch,.st {color: #036a07;} /* string */ +.kw {color: #264D66;} /* keyword */ +.co {color: #888888;} /* comment */ + +.message { color: black; font-weight: bolder;} +.error { color: orange; font-weight: bolder;} +.warning { color: #6A0366; font-weight: bolder;} + +/* Clipboard --------------------------*/ + +.hasCopyButton { + position: relative; +} + +.btn-copy-ex { + position: absolute; + right: 0; + top: 0; + visibility: hidden; +} + +.hasCopyButton:hover button.btn-copy-ex { + visibility: visible; +} + +/* headroom.js ------------------------ */ + +.headroom { + will-change: transform; + transition: transform 200ms linear; +} +.headroom--pinned { + transform: translateY(0%); +} +.headroom--unpinned { + transform: translateY(-100%); +} + +/* mark.js ----------------------------*/ + +mark { + background-color: rgba(255, 255, 51, 0.5); + border-bottom: 2px solid rgba(255, 153, 51, 0.3); + padding: 1px; +} + +/* vertical spacing after htmlwidgets */ +.html-widget { + margin-bottom: 10px; +} + +/* fontawesome ------------------------ */ + +.fab { + font-family: "Font Awesome 5 Brands" !important; +} + +/* don't display links in code chunks when printing */ +/* source: https://stackoverflow.com/a/10781533 */ +@media print { + code a:link:after, code a:visited:after { + content: ""; + } +} diff --git a/docs/pkgdown.js b/docs/pkgdown.js new file mode 100644 index 0000000..7e7048f --- /dev/null +++ b/docs/pkgdown.js @@ -0,0 +1,108 @@ +/* http://gregfranko.com/blog/jquery-best-practices/ */ +(function($) { + $(function() { + + $('.navbar-fixed-top').headroom(); + + $('body').css('padding-top', $('.navbar').height() + 10); + $(window).resize(function(){ + $('body').css('padding-top', $('.navbar').height() + 10); + }); + + $('[data-toggle="tooltip"]').tooltip(); + + var cur_path = paths(location.pathname); + var links = $("#navbar ul li a"); + var max_length = -1; + var pos = -1; + for (var i = 0; i < links.length; i++) { + if (links[i].getAttribute("href") === "#") + continue; + // Ignore external links + if (links[i].host !== location.host) + continue; + + var nav_path = paths(links[i].pathname); + + var length = prefix_length(nav_path, cur_path); + if (length > max_length) { + max_length = length; + pos = i; + } + } + + // Add class to parent
  • , and enclosing
  • if in dropdown + if (pos >= 0) { + var menu_anchor = $(links[pos]); + menu_anchor.parent().addClass("active"); + menu_anchor.closest("li.dropdown").addClass("active"); + } + }); + + function paths(pathname) { + var pieces = pathname.split("/"); + pieces.shift(); // always starts with / + + var end = pieces[pieces.length - 1]; + if (end === "index.html" || end === "") + pieces.pop(); + return(pieces); + } + + // Returns -1 if not found + function prefix_length(needle, haystack) { + if (needle.length > haystack.length) + return(-1); + + // Special case for length-0 haystack, since for loop won't run + if (haystack.length === 0) { + return(needle.length === 0 ? 0 : -1); + } + + for (var i = 0; i < haystack.length; i++) { + if (needle[i] != haystack[i]) + return(i); + } + + return(haystack.length); + } + + /* Clipboard --------------------------*/ + + function changeTooltipMessage(element, msg) { + var tooltipOriginalTitle=element.getAttribute('data-original-title'); + element.setAttribute('data-original-title', msg); + $(element).tooltip('show'); + element.setAttribute('data-original-title', tooltipOriginalTitle); + } + + if(ClipboardJS.isSupported()) { + $(document).ready(function() { + var copyButton = ""; + + $(".examples, div.sourceCode").addClass("hasCopyButton"); + + // Insert copy buttons: + $(copyButton).prependTo(".hasCopyButton"); + + // Initialize tooltips: + $('.btn-copy-ex').tooltip({container: 'body'}); + + // Initialize clipboard: + var clipboardBtnCopies = new ClipboardJS('[data-clipboard-copy]', { + text: function(trigger) { + return trigger.parentNode.textContent; + } + }); + + clipboardBtnCopies.on('success', function(e) { + changeTooltipMessage(e.trigger, 'Copied!'); + e.clearSelection(); + }); + + clipboardBtnCopies.on('error', function() { + changeTooltipMessage(e.trigger,'Press Ctrl+C or Command+C to copy'); + }); + }); + } +})(window.jQuery || window.$) diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml new file mode 100644 index 0000000..951bbf0 --- /dev/null +++ b/docs/pkgdown.yml @@ -0,0 +1,7 @@ +pandoc: '2.13' +pkgdown: 1.6.1 +pkgdown_sha: ~ +articles: + listdown: listdown.html +last_built: 2021-04-26T20:57Z + diff --git a/docs/reference/Rplot001.png b/docs/reference/Rplot001.png new file mode 100644 index 0000000..17a3580 Binary files /dev/null and b/docs/reference/Rplot001.png differ diff --git a/docs/reference/as_ld_yml.html b/docs/reference/as_ld_yml.html new file mode 100644 index 0000000..ab6844c --- /dev/null +++ b/docs/reference/as_ld_yml.html @@ -0,0 +1,184 @@ + + + + + + + + +Turn a Computational Component List into YAML with Class Information — as_ld_yml • listdown + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Create an object of type yaml::yml from a list of +computational components. The function recursively descends into the list +and when an element type is not a list the class information substituted +for the object.

    +
    + +
    as_ld_yml(x)
    + +

    Arguments

    + + + + + + +
    x

    a named list of computational components.

    + + +

    Examples

    +
    if (require("ggplot2")) { + + cc_list <- list( + Linear = ggplot(anscombe, aes(x = x1, y = y1)) + geom_point(), + `Non Linear` = ggplot(anscombe, aes(x = x2, y = y2)) + geom_point(), + `Outlier Vertical`= ggplot(anscombe, aes(x = x3, y = y3)) + geom_point(), + `Outlier Horizontal` = ggplot(anscombe, aes(x = x4, y = y4)) + + geom_point()) + + as_ld_yml(cc_list) +} +
    #> Loading required package: ggplot2
    #> [1] "Linear:\n- gg:ggplot\nNon Linear:\n- gg:ggplot\nOutlier Vertical:\n- gg:ggplot\nOutlier Horizontal:\n- gg:ggplot\n"
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.6.1.

    +
    + +
    +
    + + + + + + + + diff --git a/docs/reference/create_load_cc_expr.html b/docs/reference/create_load_cc_expr.html new file mode 100644 index 0000000..a162173 --- /dev/null +++ b/docs/reference/create_load_cc_expr.html @@ -0,0 +1,170 @@ + + + + + + + + +Create an expression to load a Computational Component — create_load_cc_expr • listdown + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    An expression to load a computational component can be either +a raw expression, a variable holding the expression, or a string. The +return is an unevaluated expression.

    +
    + +
    create_load_cc_expr(load_cc_expr)
    + +

    Arguments

    + + + + + + +
    load_cc_expr

    a string or expression that should be use to load +the computational components.

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.6.1.

    +
    + +
    +
    + + + + + + + + diff --git a/docs/reference/index.html b/docs/reference/index.html new file mode 100644 index 0000000..40ac3b1 --- /dev/null +++ b/docs/reference/index.html @@ -0,0 +1,248 @@ + + + + + + + + +Function reference • listdown + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +

    All functions

    +

    +
    +

    as_ld_yml()

    +

    Turn a Computational Component List into YAML with Class Information

    +

    create_load_cc_expr()

    +

    Create an expression to load a Computational Component

    +

    ld_build_html_site()

    +

    Build an html Site from listdown Document Bundles

    +

    ld_bundle_doc()

    +

    Create a `listdown` Document Bundle

    +

    ld_cc_dendro()

    +

    Show the list of Computational Components as a Dendrogram

    +

    ld_chunk_opts()

    +

    Apply Chunk Options to a Presentation Object

    +

    ld_create_doc()

    +

    Create a Document from a `listdown` Bundle

    +

    ld_make_chunks()

    +

    Write a listdown Object to a String

    +

    ld_rmarkdown_header()

    +

    Create an R Markdown Header

    +

    ld_site_yaml()

    +

    Create a Minimalist Site YAML List

    +

    ld_workflowr_header()

    +

    Create a workflowr Header

    +

    ld_write_file()

    +

    Write to an R Markdown File

    +

    listdown()

    +

    Create a listdown Object

    +
    + + +
    + + +
    + + +
    +

    Site built with pkgdown 1.6.1.

    +
    + +
    +
    + + + + + + + + diff --git a/docs/reference/ld_build_html_site.html b/docs/reference/ld_build_html_site.html new file mode 100644 index 0000000..f3a9e06 --- /dev/null +++ b/docs/reference/ld_build_html_site.html @@ -0,0 +1,234 @@ + + + + + + + + +Build an html Site from listdown Document Bundles — ld_build_html_site • listdown + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    This function creates an html website with each tab in the +page being desribed by a listdown document bundle.

    +
    + +
    ld_build_html_site(
    +  doc_bundles,
    +  site_yaml,
    +  rmd_dir = file.path(tempdir(), "rmarkdown"),
    +  data_dir = file.path("..", "data"),
    +  html_dir = file.path("..", "html"),
    +  render_site = TRUE,
    +  view = interactive(),
    +  make_data_dir = TRUE,
    +  make_rmd_dir = TRUE,
    +  ...
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    doc_bundles

    a named list of document bundles. There can be up to one +unnamed bundle, which will be assumed to correspond to an index.rmd file.

    site_yaml

    a list of site information, which will be written +to the _site.yml file.

    rmd_dir

    the directory where the R Markdown files will reside. By +default an "rmarkdown" file is written to `tempdir()`.

    data_dir

    the location where data can be found for each bundle. +If the data is held in memory for a listdown document bundle, then it will +be written to the specified directory. If mulitple directories are specified, +then the directory is specified per bundle, with index recycling used if +the number of directories is not the same as the number of bundles.

    html_dir

    the location of the rendered document, relative to the +directory specified by `rmd_dir`. Note that this is an rmarkdown +convention. By default a directory names "html" is created in the +directory specified by `rmd_dir` and rendered documents are place there.

    render_site

    should the page be rendered? If not then the +`html_dir` is not created.

    view

    should the output document be opened after rendering? By +default, if `render_doc` is `TRUE` and this argument is `TRUE` then +the browser will open for you to examine the output.

    make_data_dir

    if the `data_dir` directory is not present, should it +be created? This can be set to `FALSE` when data already resides on disk +to verify that it is not being created and written.

    make_rmd_dir

    if the `rmd_dir` directory is not present, should it +be created? This can be set to `FALSE` when data already resides on disk +to verify that it is not being created and written.

    ...

    argument to be passed to the `rmarkdown::render_site()` function.

    + +

    See also

    + +

    ld_bundle_doc ld_create_doc

    + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.6.1.

    +
    + +
    +
    + + + + + + + + diff --git a/docs/reference/ld_bundle_doc.html b/docs/reference/ld_bundle_doc.html new file mode 100644 index 0000000..739ed03 --- /dev/null +++ b/docs/reference/ld_bundle_doc.html @@ -0,0 +1,183 @@ + + + + + + + + +Create a `listdown` Document Bundle — ld_bundle_doc • listdown + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    A page bundle encapsulates the computational components, +R Markdown header, and listdown object. Together, these three objects +are sufficient to create a document, which can be written with the +`ld_create_document()` function.

    +
    + +
    ld_bundle_doc(cc, header, ld)
    + +

    Arguments

    + + + + + + + + + + + + + + +
    cc

    the computational component list that will be presented.

    header

    a `list` with the header information for the document.

    ld

    a `listdown` object describing how to present the computational +components.

    + +

    See also

    + +

    ld_create_document

    + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.6.1.

    +
    + +
    +
    + + + + + + + + diff --git a/docs/reference/ld_cc_dendro.html b/docs/reference/ld_cc_dendro.html new file mode 100644 index 0000000..2016e6b --- /dev/null +++ b/docs/reference/ld_cc_dendro.html @@ -0,0 +1,194 @@ + + + + + + + + +Show the list of Computational Components as a Dendrogram — ld_cc_dendro • listdown + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    This function creates text dendrograms from +a list of computational components. It is useful for +creating a dendrogram of the the computational components of a listdown +object allowing the user to view the components hierarchically.

    +
    + +
    ld_cc_dendro(x)
    + +

    Arguments

    + + + + + + +
    x

    a named list of computational components

    + + +

    Examples

    +
    if (require("ggplot2")) { + + cc_list <- list( + Linear = ggplot(anscombe, aes(x = x1, y = y1)) + geom_point(), + `Non Linear` = ggplot(anscombe, aes(x = x2, y = y2)) + geom_point(), + `Outlier Vertical`= ggplot(anscombe, aes(x = x3, y = y3)) + geom_point(), + `Outlier Horizontal` = ggplot(anscombe, aes(x = x4, y = y4)) + + geom_point()) + + ld_cc_dendro(cc_list) +} +
    #> +#> cc_list +#> |-- Linear +#> | o-- object of type(s):gg ggplot +#> |-- Non Linear +#> | o-- object of type(s):gg ggplot +#> |-- Outlier Vertical +#> | o-- object of type(s):gg ggplot +#> o-- Outlier Horizontal +#> o-- object of type(s):gg ggplot +#>
    +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.6.1.

    +
    + +
    +
    + + + + + + + + diff --git a/docs/reference/ld_chunk_opts.html b/docs/reference/ld_chunk_opts.html new file mode 100644 index 0000000..aa0f097 --- /dev/null +++ b/docs/reference/ld_chunk_opts.html @@ -0,0 +1,182 @@ + + + + + + + + +Apply Chunk Options to a Presentation Object — ld_chunk_opts • listdown + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    This function allows the user to set chunk options for +individual elements of a presentation list.

    +
    + +
    ld_chunk_opts(pres_obj, chunk_name = NULL, ..., chunk_opts = NULL)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + +
    pres_obj

    the presentation list element whose chunk options should +be modified.

    chunk_name

    the name of the chunk. By default this is NULL, +corresponding to no chunk name.

    ...

    named chunk options and their values.

    chunk_opts

    list of chunk options can be specified. Takes priority +over arguments provided to ...

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.6.1.

    +
    + +
    +
    + + + + + + + + diff --git a/docs/reference/ld_create_doc.html b/docs/reference/ld_create_doc.html new file mode 100644 index 0000000..4bcc80b --- /dev/null +++ b/docs/reference/ld_create_doc.html @@ -0,0 +1,230 @@ + + + + + + + + +Create a Document from a `listdown` Bundle — ld_create_doc • listdown + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    This function creates a document, defined by a listdown bundle +in a specified location on disk and, optionally, opens the document in the +browser.

    +
    + +
    ld_create_doc(
    +  ldb,
    +  rmd_file_name = basename(tempfile(pattern = "rmarkdown", fileext = ".rmd")),
    +  rmd_dir = file.path(tempdir(), "rmarkdown"),
    +  output_dir = file.path(rmd_dir, "pres"),
    +  render_doc = TRUE,
    +  cc_file_name = NULL,
    +  data_dir = NULL,
    +  view = interactive(),
    +  ...
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ldb

    a listdown doc bundle.

    rmd_file_name

    the name of the R Markdown file to create. By default, +a temporary file is created.

    rmd_dir

    the directory where the output R Markdown file should be +written to. By default, this is `tempdir()`.

    output_dir

    the location of the rendered document, relative to the +directory specified by `rmd_dir`. Note that this is an rmarkdown +convention. By default a directory names "pres" is created in the +directory specified by `rmd_dir` and rendered documents are place there.

    render_doc

    should the page be rendered? If not then the +`output_dir` is not created.

    cc_file_name

    the name of the list specifying the computational +components. If this is `NULL` (the default) then the listdown bundle +is checked to make sure it's `load_cc_expr` attribute has been specified. +If it is specified, and the bundles `load_cc_expr` has not been specified, +then it will be written to disk (in the corresponding data directory, +specified by `data_dir`) and read via the `saveRDS()` function.

    data_dir

    the directory where data should be written. If the +`cc_file_name` argument is `NULL` then this argument is ignored. If the +`cc_file_name` argument is specfied but `data_dir` is not, then `tempdir()` +is used.

    view

    should the output document be opened after rendering? By +default, if `render_doc` is `TRUE` and this argument is `TRUE` then +the browser will open for you to examine the output.

    ...

    options to send to the rmarkdown::render() function.

    + +

    See also

    + +

    ld_bundle_doc

    + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.6.1.

    +
    + +
    +
    + + + + + + + + diff --git a/docs/reference/ld_make_chunks.html b/docs/reference/ld_make_chunks.html new file mode 100644 index 0000000..f2e5a15 --- /dev/null +++ b/docs/reference/ld_make_chunks.html @@ -0,0 +1,176 @@ + + + + + + + + +Write a listdown Object to a String — ld_make_chunks • listdown + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    After a presentation list and listdown object have been +constructed the chunks can be rendered to a string, which can be appended +to a file, with appropriate headers, resulting in a compilable R Markdown +document.

    +
    + +
    ld_make_chunks(ld, rmd_dir)
    + +

    Arguments

    + + + + + + +
    ld

    the listdown object that provides +information on how a presentation object should be displayed in the +output.

    + +

    See also

    + + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.6.1.

    +
    + +
    +
    + + + + + + + + diff --git a/docs/reference/ld_rmarkdown_header.html b/docs/reference/ld_rmarkdown_header.html new file mode 100644 index 0000000..1308bb7 --- /dev/null +++ b/docs/reference/ld_rmarkdown_header.html @@ -0,0 +1,183 @@ + + + + + + + + +Create an R Markdown Header — ld_rmarkdown_header • listdown + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Output an R Markdown header with specified parameters.

    +
    + +
    ld_rmarkdown_header(
    +  title,
    +  author = NULL,
    +  date = NULL,
    +  output = c("html_document", "pdf_document", "word_document")
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + +
    title

    the title of the page.

    author

    the author of the page. The default is NULL - no author.

    date

    the date for the page. The default is NULL - no date.

    output

    the output format of the page. If NULL then no output format. +The default is an html document.

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.6.1.

    +
    + +
    +
    + + + + + + + + diff --git a/docs/reference/ld_site_yaml.html b/docs/reference/ld_site_yaml.html new file mode 100644 index 0000000..4c7f2f0 --- /dev/null +++ b/docs/reference/ld_site_yaml.html @@ -0,0 +1,179 @@ + + + + + + + + +Create a Minimalist Site YAML List — ld_site_yaml • listdown + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Create a Minimalist Site YAML List

    +
    + +
    ld_site_yaml(site_name, tab_name, rmd_name, navbar_title = site_name)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + +
    site_name

    the name of the site.

    tab_name

    the name of the tabs on the site.

    rmd_name

    the name of the Rmarkdown files that will generate the +respective tabs.

    navbar_title

    the title of the navigation bar (Default is the +`site_name` argument.

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.6.1.

    +
    + +
    +
    + + + + + + + + diff --git a/docs/reference/ld_workflowr_header.html b/docs/reference/ld_workflowr_header.html new file mode 100644 index 0000000..fab8446 --- /dev/null +++ b/docs/reference/ld_workflowr_header.html @@ -0,0 +1,169 @@ + + + + + + + + +Create a workflowr Header — ld_workflowr_header • listdown + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    Output a workflowr R Markdown header with specified title.

    +
    + +
    ld_workflowr_header(title, toc = FALSE)
    + +

    Arguments

    + + + + + + + + + + +
    title

    the title of the page.

    toc

    should the table of contents be generated? Default FALSE.

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.6.1.

    +
    + +
    +
    + + + + + + + + diff --git a/docs/reference/ld_write_file.html b/docs/reference/ld_write_file.html new file mode 100644 index 0000000..8ab7ac0 --- /dev/null +++ b/docs/reference/ld_write_file.html @@ -0,0 +1,178 @@ + + + + + + + + +Write to an R Markdown File — ld_write_file • listdown + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    This function takes header information and a listdown +object and writes to a specified file.

    +
    + +
    ld_write_file(rmd_header, ld, file_name)
    + +

    Arguments

    + + + + + + + + + + + + + + +
    rmd_header

    either a character or listdown_header with R Markdown +header information.

    ld

    the listdown object that provides +information on how a presentation object should be displayed in the +output.

    file_name

    the output file to write to.

    + + +
    + +
    + + +
    + + +
    +

    Site built with pkgdown 1.6.1.

    +
    + +
    +
    + + + + + + + + diff --git a/docs/reference/listdown.html b/docs/reference/listdown.html new file mode 100644 index 0000000..d72c67a --- /dev/null +++ b/docs/reference/listdown.html @@ -0,0 +1,230 @@ + + + + + + + + +Create a listdown Object — listdown • listdown + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + +
    + +
    +
    + + +
    +

    A listdown object provides information for how a presentation +list should be used to create an R Markdown document. It requires an +unquoted expression indicating how the presentation list will be loaded. +In addition, libraries required by the outputted document and other +parameters can be specified.

    +
    + +
    listdown(
    +  package = NULL,
    +  decorator = list(),
    +  decorator_chunk_opts = list(),
    +  default_decorator = identity,
    +  setup_expr = NULL,
    +  init_expr = NULL,
    +  load_cc_expr = NULL,
    +  ...,
    +  chunk_opts = NULL
    +)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    package

    a quoted list of package required by the outputted document.

    decorator

    a named list mapping the potential types of list elements +to a decorator function.

    decorator_chunk_opts

    a named list mapping the potential types of list +elements to chunk options that should be included for those types.

    default_decorator

    the decorator to use for list elements whose type +is not inherited from the decorator list. If NULL then the those +elements will not be included when the chunks are written. By default +this is identity, meaning that the elements will be passed directly +(through the identity() function).

    setup_expr

    an expression that is added before package are +loaded. The expression is put into a chunk named `setup` with option +`include = FALSE` and is intended for initializing the document. For +example the expression `knitr::opts_chunk$set(echo = FALSE)` could be +used to turn echo'ing off for the entire document.

    init_expr

    an initial expression that will be added to the outputted +document after the libraries have been called. This expression appears +after packages are loaded and before data is read.

    load_cc_expr

    either an unquoted expression or a character string +that will be turned into an unquoted expression via str2lang to load the +presentation list.

    ...

    default options sent to the chunks of the outputted document.

    chunk_opts

    a named list of options sent to the chunks of outputted +documents. Note: takes priority over argument provided to ...

    + + +
    + +
    + + + +
    + + + + + + + +