├── .Rbuildignore ├── .Rinstignore ├── .github ├── .gitignore ├── CONTRIBUTING.md ├── FUNDING.yml ├── ISSUE_TEMPLATE.md ├── actions │ └── checkout-knitr-examples │ │ └── action.yml └── workflows │ ├── R-CMD-check.yaml │ ├── github-pages.yml │ ├── knitr-examples.yaml │ └── lock.yaml ├── .gitignore ├── DESCRIPTION ├── FAQ.md ├── Makefile ├── NAMESPACE ├── NEWS.md ├── R ├── block.R ├── cache.R ├── citation.R ├── concordance.R ├── defaults.R ├── engine.R ├── header.R ├── highlight.R ├── hooks-asciidoc.R ├── hooks-chunk.R ├── hooks-extra.R ├── hooks-html.R ├── hooks-latex.R ├── hooks-md.R ├── hooks-rst.R ├── hooks-textile.R ├── hooks.R ├── output.R ├── package.R ├── pandoc.R ├── params.R ├── parser.R ├── pattern.R ├── plot.R ├── rocco.R ├── spin.R ├── table.R ├── template.R ├── themes.R ├── utils-conversion.R ├── utils-rd2html.R ├── utils-string.R ├── utils-sweave.R ├── utils-upload.R ├── utils-vignettes.R ├── utils.R └── zzz.R ├── README-ES.md ├── README-PT.md ├── README.md ├── codecov.yml ├── docs └── README.md ├── inst ├── CITATION ├── NEWS.Rd ├── bin │ └── knit ├── examples │ ├── README.md │ ├── child │ │ ├── knitr-child-a.Rnw │ │ ├── knitr-child-b.Rnw │ │ ├── knitr-child.Rmd │ │ ├── knitr-child2.Rmd │ │ ├── knitr-main.Rmd │ │ ├── knitr-main.Rnw │ │ ├── knitr-main.md │ │ ├── knitr-parent.Rnw │ │ └── sub │ │ │ └── knitr-child-c.Rnw │ ├── knit-all.R │ ├── knitr-beamer.Rnw │ ├── knitr-beamer.lyx │ ├── knitr-graphics.Rnw │ ├── knitr-graphics.lyx │ ├── knitr-input-child.Rnw │ ├── knitr-input.Rnw │ ├── knitr-latex.Rtex │ ├── knitr-listings.Rnw │ ├── knitr-listings.lyx │ ├── knitr-manual.Rnw │ ├── knitr-manual.bib │ ├── knitr-manual.lyx │ ├── knitr-minimal.Rmd │ ├── knitr-minimal.Rnw │ ├── knitr-minimal.Rrst │ ├── knitr-minimal.brew │ ├── knitr-minimal.lyx │ ├── knitr-minimal.md │ ├── knitr-packages.bib │ ├── knitr-spin.R │ ├── knitr-spin.Rmd │ ├── knitr-subfloats.Rnw │ ├── knitr-subfloats.lyx │ ├── knitr-themes.Rnw │ ├── knitr-themes.lyx │ ├── knitr-twocolumn.Rnw │ └── knitr-twocolumn.lyx ├── misc │ ├── R.css │ ├── Sweavel.sty │ ├── knitr-template.Rhtml │ ├── knitr-template.Rmd │ ├── knitr-template.Rnw │ ├── knitr.css │ ├── knitr.sty │ ├── stitch-test.R │ ├── tikz2pdf.tex │ ├── toggleR.js │ ├── vignette.css │ └── vignette.html ├── opencpu │ └── apps │ │ └── index.html └── themes │ ├── acid.css │ ├── aiseered.css │ ├── andes.css │ ├── anotherdark.css │ ├── autumn.css │ ├── baycomb.css │ ├── bclear.css │ ├── biogoo.css │ ├── bipolar.css │ ├── blacknblue.css │ ├── bluegreen.css │ ├── breeze.css │ ├── bright.css │ ├── camo.css │ ├── candy.css │ ├── clarity.css │ ├── dante.css │ ├── darkblue.css │ ├── darkbone.css │ ├── darkness.css │ ├── darkslategray.css │ ├── darkspectrum.css │ ├── default.css │ ├── denim.css │ ├── dusk.css │ ├── earendel.css │ ├── easter.css │ ├── edit-anjuta.css │ ├── edit-eclipse.css │ ├── edit-emacs.css │ ├── edit-flashdevelop.css │ ├── edit-gedit.css │ ├── edit-jedit.css │ ├── edit-kwrite.css │ ├── edit-matlab.css │ ├── edit-msvs2008.css │ ├── edit-nedit.css │ ├── edit-vim-dark.css │ ├── edit-vim.css │ ├── edit-xcode.css │ ├── ekvoli.css │ ├── fine_blue.css │ ├── freya.css │ ├── fruit.css │ ├── golden.css │ ├── greenlcd.css │ ├── greyscale0.css │ ├── greyscale1.css │ ├── greyscale2.css │ ├── kellys.css │ ├── leo.css │ ├── lucretia.css │ ├── manxome.css │ ├── maroloccio.css │ ├── matrix.css │ ├── moe.css │ ├── molokai.css │ ├── moria.css │ ├── navajo-night.css │ ├── navy.css │ ├── neon.css │ ├── night.css │ ├── nightshimmer.css │ ├── nuvola.css │ ├── olive.css │ ├── orion.css │ ├── oxygenated.css │ ├── pablo.css │ ├── peaksea.css │ ├── print.css │ ├── rand01.css │ ├── rdark.css │ ├── relaxedgreen.css │ ├── rootwater.css │ ├── seashell.css │ ├── solarized-dark.css │ ├── solarized-light.css │ ├── tabula.css │ ├── tcsoft.css │ ├── vampire.css │ ├── whitengrey.css │ ├── xoria256.css │ ├── zellner.css │ ├── zenburn.css │ └── zmrok.css ├── knitr.Rproj ├── man ├── Sweave2knitr.Rd ├── all_labels.Rd ├── all_patterns.Rd ├── asis_output.Rd ├── cache_engines.Rd ├── chunk_hook.Rd ├── clean_cache.Rd ├── combine_words.Rd ├── convert_chunk_header.Rd ├── current_input.Rd ├── dep_auto.Rd ├── dep_prev.Rd ├── download_image.Rd ├── engine_output.Rd ├── fig_chunk.Rd ├── fig_path.Rd ├── hook_animation.Rd ├── hook_document.Rd ├── hook_plot.Rd ├── image_uri.Rd ├── imgur_upload.Rd ├── include_graphics.Rd ├── include_url.Rd ├── inline_expr.Rd ├── is_low_change.Rd ├── kable.Rd ├── knit.Rd ├── knit2html.Rd ├── knit2pandoc.Rd ├── knit2pdf.Rd ├── knit2wp.Rd ├── knit_child.Rd ├── knit_code.Rd ├── knit_engines.Rd ├── knit_exit.Rd ├── knit_expand.Rd ├── knit_filter.Rd ├── knit_global.Rd ├── knit_hooks.Rd ├── knit_meta.Rd ├── knit_params.Rd ├── knit_params_yaml.Rd ├── knit_patterns.Rd ├── knit_print.Rd ├── knit_rd.Rd ├── knit_theme.Rd ├── knit_watch.Rd ├── knitr-package.Rd ├── load_cache.Rd ├── opts_chunk.Rd ├── opts_hooks.Rd ├── opts_knit.Rd ├── opts_template.Rd ├── output_hooks.Rd ├── output_type.Rd ├── pandoc.Rd ├── partition_chunk.Rd ├── pat_fun.Rd ├── plot_crop.Rd ├── rand_seed.Rd ├── raw_block.Rd ├── raw_output.Rd ├── read_chunk.Rd ├── rnw2pdf.Rd ├── rocco.Rd ├── rst2pdf.Rd ├── set_alias.Rd ├── set_header.Rd ├── set_parent.Rd ├── sew.Rd ├── spin.Rd ├── spin_child.Rd ├── stitch.Rd ├── vignette_engines.Rd ├── wrap_rmd.Rd └── write_bib.Rd ├── tests ├── run-all.R └── testit │ ├── acid.style │ ├── knit-envir.Rmd │ ├── knit-handlers.Rmd │ ├── knit-tikzDevice.Rnw │ ├── test-block.R │ ├── test-cache.R │ ├── test-closure.R │ ├── test-envir.R │ ├── test-hooks-latex.R │ ├── test-hooks-md.R │ ├── test-output.R │ ├── test-params.R │ ├── test-parser.R │ ├── test-patterns.R │ ├── test-plot.R │ ├── test-spin.R │ ├── test-sql.R │ ├── test-table.R │ ├── test-tangle.R │ ├── test-templates.R │ ├── test-themes.R │ └── test-utils.R └── vignettes ├── datatables.Rmd ├── docco-classic.Rmd ├── docco-linear.Rmd ├── knit_expand.Rmd ├── knit_print.Rmd ├── knitr-html.Rhtml ├── knitr-intro.Rmd ├── knitr-markdown.Rmd └── knitr-refcard.Rmd /.Rbuildignore: -------------------------------------------------------------------------------- 1 | .gitignore 2 | tikzDictionary$ 3 | aux$ 4 | log$ 5 | out$ 6 | inst/examples/knitr-.*.pdf 7 | inst/examples/Sweavel.sty 8 | inst/examples/.*\.bib 9 | inst/examples/child/knitr-.*.pdf 10 | inst/examples/child/knitr-.*\.md 11 | inst/examples/figure 12 | inst/examples/cache 13 | knitr-minimal.md 14 | knitr-spin.md 15 | png$ 16 | ^\.Rproj\.user$ 17 | ^.*\.Rproj$ 18 | FAQ.md 19 | Makefile 20 | ^\.github$ 21 | ^docs$ 22 | ^README.*\.md$ 23 | ^codecov\.yml$ 24 | ^NEWS\.md$ 25 | ^cran-comments\.md$ 26 | -------------------------------------------------------------------------------- /.Rinstignore: -------------------------------------------------------------------------------- 1 | knitr-intro.lyx 2 | -------------------------------------------------------------------------------- /.github/.gitignore: -------------------------------------------------------------------------------- 1 | *.html 2 | -------------------------------------------------------------------------------- /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | You may expedite bug fixes and new features by doing the work by yourself. 2 | For very simple changes such as fixing typos, you can just edit the file by 3 | clicking the button `Edit` after you open it here on Github. For more 4 | complicated changes, you will have to manually create a [pull 5 | request](https://help.github.com/articles/using-pull-requests) (PR) after 6 | [forking](https://help.github.com/articles/fork-a-repo) this repository. In the 7 | latter case, you are recommended to create a new branch instead of always 8 | working on the `master` branch. 9 | 10 | If you submit a non-trivial pull request (e.g. not just fixing a typo), please add an item to `NEWS.md`, and 11 | add your name to the `Authors@R` field as a contributor (`ctb`) in the R package `DESCRIPTION` file. 12 | 13 | ## Testing 14 | 15 | To make sure you did not break anything, you need to run tests, which are 16 | done through the [**testit**](http://cran.rstudio.com/package=testit) 17 | package. If you added any features, add your own tests in `tests/testit/`. 18 | 19 | ## Travis CI 20 | 21 | If you are lazy or do not understand what I said above, just push commits to 22 | your repo, submit a PR, and wait for a few minutes. 23 | [Travis CI](http://yihui.name/en/2013/04/travis-ci-general-purpose/) will run 24 | the tests automatically. If your pull request passes the tests, you see 25 | green check marks, otherwise you see red crosses, and you will probably get 26 | email notifications as well. 27 | 28 | - [An example PR that passed the 29 | check](https://github.com/yihui/knitr/pull/852/commits) 30 | - [An example PR that failed](https://github.com/yihui/knitr/pull/832/commits) 31 | 32 | When your PR does not pass the check, you need to click on the red cross to see 33 | details. There are two sets of tests: `R CMD check` on the package source, as 34 | well as the test on examples. The former is basically the unit tests, and the 35 | latter is to make sure your changes does not break my existing examples in the 36 | [knitr-examples](https://github.com/yihui/knitr-examples). 37 | 38 | ## roxygen2 documentation 39 | 40 | If your changes involve the roxygen2 documentation, please run `Rd2roxygen::rab('.')` to generate the Rd files. 41 | 42 | ## Misc 43 | 44 | For a non-trivial fix or feature implementation, please let me know before you 45 | start working on it, since I do not want to waste too much of your time on 46 | something that I may not really want. 47 | 48 | Thanks, and happy hacking. 49 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: [yihui] 2 | patreon: 3 | custom: 4 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | --- 8 | 9 | By filing an issue to this repo, I promise that 10 | 11 | - [ ] I have fully read the issue guide at https://yihui.org/issue/. 12 | - [ ] I have provided the necessary information about my issue. 13 | - If I'm asking a question, I have already asked it on Stack Overflow or RStudio Community, waited for at least 24 hours, and included a link to my question there. 14 | - If I'm filing a bug report, I have included a minimal, self-contained, and reproducible example, and have also included `xfun::session_info('knitr')`. I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version: `remotes::install_github('yihui/knitr')`. 15 | - If I have posted the same issue elsewhere, I have also mentioned it in this issue. 16 | - [ ] I have learned the Github Markdown syntax, and formatted my issue correctly. 17 | 18 | I understand that my issue may be closed if I don't fulfill my promises. 19 | -------------------------------------------------------------------------------- /.github/actions/checkout-knitr-examples/action.yml: -------------------------------------------------------------------------------- 1 | name: 'Checkout knitr-example' 2 | author: Christophe Dervieux 3 | description: 'Checkout knitr-example project on the right branch, i.e same branch name as the current PR main branch' 4 | runs: 5 | using: "composite" 6 | steps: 7 | - name: Determine branch name 8 | id: check-branch 9 | env: 10 | GH_TOKEN: ${{ github.token }} 11 | run: | 12 | headref="${{ github.head_ref }}" 13 | if [ -z "$headref" ] 14 | then 15 | echo '::debug::Not on pull request - using main ref branch' 16 | branch='' 17 | else 18 | echo '::debug::On pull request' 19 | branch=$(gh api repos/yihui/knitr-examples/branches | jq -cr '.[] | select(.name == '\"$headref\"') | .name') 20 | fi 21 | echo "ref=$(echo $branch)" >> "$GITHUB_OUTPUT" 22 | shell: bash 23 | - name: Retrieve knitr-examples 24 | uses: actions/checkout@v2 25 | with: 26 | repository: yihui/knitr-examples 27 | path: knitr-examples 28 | ref: ${{ steps.check-branch.outputs.ref }} 29 | clean: false 30 | -------------------------------------------------------------------------------- /.github/workflows/github-pages.yml: -------------------------------------------------------------------------------- 1 | name: Build and deploy package site 2 | 3 | on: 4 | push: 5 | branches: ["master"] 6 | 7 | permissions: 8 | contents: read 9 | pages: write 10 | id-token: write 11 | 12 | jobs: 13 | deploy: 14 | environment: 15 | name: github-pages 16 | url: ${{ steps.deployment.outputs.page_url }} 17 | runs-on: ubuntu-latest 18 | steps: 19 | - uses: actions/checkout@v4 20 | - uses: actions/configure-pages@v5 21 | with: 22 | enablement: true 23 | - uses: r-lib/actions/setup-r@HEAD 24 | with: 25 | use-public-rspm: true 26 | - uses: r-lib/actions/setup-r-dependencies@HEAD 27 | - uses: yihui/litedown/site@HEAD 28 | with: 29 | site-dir: 'site' 30 | - uses: actions/upload-pages-artifact@v3 31 | with: 32 | path: 'site' 33 | - id: deployment 34 | uses: actions/deploy-pages@v4 35 | -------------------------------------------------------------------------------- /.github/workflows/lock.yaml: -------------------------------------------------------------------------------- 1 | # From https://github.com/marketplace/actions/lock-threads 2 | name: 'Lock threads' 3 | 4 | on: 5 | schedule: 6 | - cron: '10 5 * * 3' 7 | 8 | jobs: 9 | lock: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: dessant/lock-threads@v4 13 | with: 14 | github-token: ${{ github.token }} 15 | issue-inactive-days: '180' 16 | # exclude-issue-created-before: '' 17 | # exclude-issue-created-after: '' 18 | # exclude-issue-created-between: '' 19 | # exclude-issue-closed-before: '' 20 | # exclude-issue-closed-after: '' 21 | # exclude-issue-closed-between: '' 22 | # include-any-issue-labels: '' 23 | # include-all-issue-labels: '' 24 | # exclude-any-issue-labels: '' 25 | # add-issue-labels: '' 26 | # remove-issue-labels: '' 27 | issue-comment: > 28 | This old thread has been automatically locked. If you think you have 29 | found something related to this, please open a new issue by following 30 | the issue guide (), and link to this 31 | old issue if necessary. 32 | issue-lock-reason: 'resolved' 33 | pr-inactive-days: '180' 34 | # exclude-pr-created-before: '' 35 | # exclude-pr-created-after: '' 36 | # exclude-pr-created-between: '' 37 | # exclude-pr-closed-before: '' 38 | # exclude-pr-closed-after: '' 39 | # exclude-pr-closed-between: '' 40 | # include-any-pr-labels: '' 41 | # include-all-pr-labels: '' 42 | # exclude-any-pr-labels: '' 43 | # add-pr-labels: '' 44 | # remove-pr-labels: '' 45 | # pr-comment: '' 46 | # pr-lock-reason: 'resolved' 47 | # process-only: '' 48 | # log-output: false 49 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *-tikzDictionary 2 | *.aux 3 | *.log 4 | *.out 5 | knitr-*.pdf 6 | inst/examples/cache 7 | inst/examples/figure 8 | knitr-spin.md 9 | knitr-spin.html 10 | .Rproj.user 11 | /.Rhistory 12 | /inst/examples/*.tex 13 | /inst/examples/*.sty 14 | .*.Rnb.cached 15 | -------------------------------------------------------------------------------- /FAQ.md: -------------------------------------------------------------------------------- 1 | This page has been moved to . 2 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # prepare the package for release 2 | PKGNAME := $(shell sed -n "s/Package: *\([^ ]*\)/\1/p" DESCRIPTION) 3 | PKGVERS := $(shell sed -n "s/Version: *\([^ ]*\)/\1/p" DESCRIPTION) 4 | PKGSRC := $(shell basename `pwd`) 5 | 6 | all: check clean 7 | 8 | deps: 9 | tlmgr install pgf preview xcolor;\ 10 | Rscript -e 'if (!require("Rd2roxygen")) install.packages("Rd2roxygen", repos="http://cran.rstudio.com")' 11 | 12 | docs: 13 | R -q -e 'library(Rd2roxygen); rab(".", build = FALSE)' 14 | 15 | build: 16 | cd ..;\ 17 | R CMD build --no-manual $(PKGSRC) 18 | 19 | build-cran: 20 | cd ..;\ 21 | R CMD build $(PKGSRC) 22 | 23 | install: build 24 | cd ..;\ 25 | R CMD INSTALL $(PKGNAME)_$(PKGVERS).tar.gz 26 | 27 | check: build-cran 28 | cd ..;\ 29 | R CMD check $(PKGNAME)_$(PKGVERS).tar.gz --as-cran 30 | 31 | travis: build 32 | cd ..;\ 33 | R CMD check $(PKGNAME)_$(PKGVERS).tar.gz --no-manual 34 | 35 | integration-run: 36 | xvfb-run make deps knit -C knitr-examples 37 | 38 | integration-verify: 39 | GIT_PAGER=cat make diff -C knitr-examples 40 | 41 | integration: install integration-run integration-verify 42 | 43 | examples: 44 | cd inst/examples;\ 45 | Rscript knit-all.R 46 | 47 | clean: 48 | cd ..;\ 49 | $(RM) -r $(PKGNAME).Rcheck/ 50 | 51 | -------------------------------------------------------------------------------- /R/citation.R: -------------------------------------------------------------------------------- 1 | #' Generate BibTeX bibliography databases for R packages 2 | #' 3 | #' A wrapper function of \code{xfun::pkg_bib()}. 4 | #' @param ...,prefix Arguments passed to \code{xfun::\link[xfun]{pkg_bib}()}. 5 | #' @export 6 | write_bib = function(..., prefix = getOption('knitr.bib.prefix', 'R-')) { 7 | xfun::pkg_bib(..., prefix = prefix) 8 | } 9 | -------------------------------------------------------------------------------- /R/concordance.R: -------------------------------------------------------------------------------- 1 | #' @include defaults.R 2 | 3 | # record input/output lines numbers in Rnw/tex and filenames 4 | knit_concord = new_defaults(list( 5 | inlines = NULL, outlines = NULL, infile = NULL, outfile = NULL, block = NULL, offset = NULL 6 | )) 7 | 8 | # do not consider child mode for concordance 9 | concord_mode = function() { 10 | opts_knit$get('concordance') && !child_mode() 11 | } 12 | 13 | current_lines = function(i = knit_concord$get('block')) { 14 | # a helpr function to return line numbers for block i 15 | n = knit_concord$get('inlines') 16 | n1 = sum(head(n, i)); n0 = min(n1, n1 - n[i] + 1) 17 | # adjust line numbers for inline code expressions 18 | if (length(o <- knit_concord$get('offset')) == 2) { 19 | n1 = n0 + o[2]; n0 = n0 + o[1] 20 | } 21 | paste(c(n0, n1), collapse = '-') 22 | } 23 | 24 | # generate concordance for RStudio 25 | concord_gen = function(infile, outfile) { 26 | if (!concord_mode()) return() 27 | i = knit_concord$get('inlines'); o = knit_concord$get('outlines') 28 | if (is.null(i) || is.null(o)) { 29 | warning('cannot generate concordance due to incomplete line numbers') 30 | return() 31 | } 32 | stopifnot(length(i) == length(o)) 33 | 34 | steps = NULL # how many steps to jump forward to match output line numbers 35 | for (k in seq_along(i)) { 36 | steps = c(steps, if (o[k] >= i[k]) { 37 | rep(c(1L, 0L), c(i[k], o[k] - i[k])) 38 | } else { 39 | c(rep(1L, o[k] - 1L), i[k] - o[k] + 1L) 40 | }) 41 | } 42 | 43 | # generate data structure 44 | vals = rle(steps) 45 | vals = c(1L, as.numeric(rbind(vals$lengths, vals$values))) 46 | concordance = paste(strwrap(paste(vals, collapse = ' ')), collapse = ' %\n') 47 | 48 | # write to file 49 | if (is_html_output()) { 50 | cat( 51 | '\n', 52 | sep = '', file = outfile, append = TRUE 53 | ) 54 | } else if (is_latex_output()) { 55 | confile = paste(sans_ext(outfile), 'concordance.tex', sep = '-') 56 | cat('\\Sconcordance{concordance:', outfile, ':', infile, ':%\n', 57 | concordance, '}\n', sep = '', file = confile) 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /R/hooks-asciidoc.R: -------------------------------------------------------------------------------- 1 | #' @rdname hook_plot 2 | #' @export 3 | hook_plot_asciidoc = function(x, options) { 4 | base = opts_knit$get('base.url') %n% '' 5 | cap = .img.cap(options) 6 | 7 | width = sprintf('width=%s', options$out.width) 8 | height = sprintf('height=%s', options$out.height) 9 | align = sprintf('align=%s', options$fig.align) 10 | tags = paste(c(cap, width, height, align), collapse = ',') 11 | 12 | sprintf('.%s\nimage::%s%s[%s]\n', cap, base, .upload.url(x), tags) 13 | } 14 | 15 | #' @rdname output_hooks 16 | #' @export 17 | render_asciidoc = function() { 18 | set_html_dev() 19 | opts_knit$set(out.format = 'asciidoc') 20 | knit_hooks$set(hooks_asciidoc()) 21 | } 22 | 23 | #' @rdname output_hooks 24 | #' @export 25 | hooks_asciidoc = function() { 26 | hook.source = function(x, options) { 27 | x = one_string(c(hilight_source(x, 'asciidoc', options), '')) 28 | sprintf('\n[source,%s]\n----\n%s----\n', tolower(options$engine), x) 29 | } 30 | hook.message = function(x, options) { 31 | sprintf('\n[NOTE]\n====\n.Message\n%s\n====\n', substring(x, comment_length(options$comment))) 32 | } 33 | hook.warning = function(x, options) { 34 | sprintf('\n[WARNING]\n====\n.Warning\n%s\n====\n', gsub('^.*Warning: ', '', x)) 35 | } 36 | hook.error = function(x, options) { 37 | sprintf('\n[CAUTION]\n====\n.Error\n%s\n====\n', gsub('^.*Error: ', '', x)) 38 | } 39 | hook.output = function(x, options) { 40 | if (output_asis(x, options)) x else sprintf('\n----\n%s----\n', x) 41 | } 42 | list( 43 | source = hook.source, output = hook.output, message = hook.message, 44 | warning = hook.warning, error = hook.error, plot = hook_plot_asciidoc 45 | ) 46 | } 47 | 48 | comment_length = function(x) { 49 | (if (is.null(x) || !nzchar(x) || is.na(x)) 0L else nchar(x)) + 1L 50 | } 51 | -------------------------------------------------------------------------------- /R/hooks-chunk.R: -------------------------------------------------------------------------------- 1 | # hooks that return character values will be inserted into final output 2 | run_hooks = function(before, options, envir = knit_global()) { 3 | # default and user-defined new hooks 4 | hooks.n = knit_hooks$get() 5 | hooks.a = hooks.n[setdiff(names(hooks.n), names(.default.hooks))] # a list of hooks to run 6 | out = NULL 7 | nms = intersect(names(options), names(hooks.a)) 8 | if (!before) nms = rev(nms) 9 | for (i in nms) { 10 | # run only when option is not NULL, and hook is not NULL 11 | if (is.null(options[[i]]) || is.null(hook <- hooks.a[[i]])) next 12 | if (is.character(hook)) hook = get(hook, envir = envir, mode = 'function') 13 | args = list(before = before, options = options, envir = envir, name = i) 14 | anms = names(formals(hook)) 15 | if (!('...' %in% anms)) args = args[anms] 16 | res = do.call(hook, args, envir = envir) 17 | if (is.character(res)) out = c(out, res) 18 | } 19 | out 20 | } 21 | -------------------------------------------------------------------------------- /R/hooks-textile.R: -------------------------------------------------------------------------------- 1 | #' @rdname hook_plot 2 | #' @export 3 | hook_plot_textile = function(x, options) { 4 | cap = .img.cap(options); if (is.na(cap)) cap = '' 5 | 6 | tags = unlist(c(Map( 7 | sprintf, c('width: %s', 'height: %s'), 8 | options[c('out.width', 'out.height')] 9 | ), css_align(options$fig.align))) 10 | tags = if (length(tags)) sprintf('{%s}', paste(tags, collapse = ';')) else '' 11 | 12 | paste0( 13 | '!', tags, opts_knit$get('base.url'), .upload.url(x), 14 | if (nzchar(cap)) sprintf('(%s)', cap), '!\n\n', 15 | if (nzchar(cap)) sprintf('p(knitr plot caption#%s). %s', options$label, cap), 16 | '\n\n' 17 | ) 18 | } 19 | 20 | #' @rdname output_hooks 21 | #' @export 22 | render_textile = function() { 23 | set_html_dev() 24 | opts_knit$set(out.format = 'textile') 25 | knit_hooks$set(hooks_textile()) 26 | } 27 | 28 | #' @rdname output_hooks 29 | #' @export 30 | hooks_textile = function() { 31 | hook = function(name) { 32 | force(name) 33 | function(x, options) { 34 | if (name == 'source') x = c(hilight_source(x, 'textile', options), '') 35 | x = one_string(x) 36 | if (name == 'output' && output_asis(x, options)) return(x) 37 | sprintf('bc(knitr %s %s#%s).. %s\np(knitr_end). \n\n', 38 | tolower(options$engine), name, options$label, x) 39 | } 40 | } 41 | list( 42 | source = hook('source'), output = hook('output'), warning = hook('warning'), 43 | message = hook('message'), error = hook('error'), plot = hook_plot_textile, 44 | inline = function(x) .inline.hook(format_sci(x, 'html')) 45 | ) 46 | } 47 | -------------------------------------------------------------------------------- /R/package.R: -------------------------------------------------------------------------------- 1 | #' A general-purpose tool for dynamic report generation in R 2 | #' 3 | #' The \pkg{knitr} package is an implementation of Literate Programming, a 4 | #' programming paradigm that intermingle code chunks (for computing) with prose 5 | #' (for documentation) in the same document. 6 | #' 7 | #' When the document is compiled, the code chunks can be executed, and the 8 | #' results from computing (text or graphics) are automatically written to the 9 | #' output along with the prose. 10 | #' 11 | #' This package is an alternative tool to Sweave with a more flexible design and 12 | #' new features like caching and finer control of graphics. It is not limited to 13 | #' LaTeX and is ready to be customized to process other file formats. See the 14 | #' package website in the references for more information and examples. 15 | #' @name knitr-package 16 | #' @aliases knitr 17 | #' @import graphics grDevices stats utils 18 | #' @author Yihui Xie <\url{https://yihui.org}> 19 | #' @seealso The core function in this package: \code{\link{knit}}. If you are an 20 | #' Sweave user, see \code{\link{Sweave2knitr}} on how to convert Sweave files 21 | #' to \pkg{knitr}. 22 | #' @note The pronunciation of \pkg{knitr} is similar to \emph{neater} or you can 23 | #' think of \emph{knitter} (but it is \emph{single t}). The name comes from 24 | #' \code{knit} + \code{R} (while \code{Sweave} = \code{S} + \code{weave}). 25 | #' @references Full documentation and demos: \url{https://yihui.org/knitr/}; 26 | #' FAQ's: \url{https://yihui.org/knitr/faq/} 27 | #' @importFrom xfun file_ext html_escape is_windows loadable parse_only 28 | #' sans_ext try_silent with_ext read_utf8 write_utf8 file_string 29 | #' is_R_CMD_check is_abs_path 30 | '_PACKAGE' 31 | 32 | .knitEnv = new.env() 33 | 34 | .knitEnv$meta = list() 35 | 36 | # no partial matching for lists!! 37 | #' @export 38 | `$.knitr_strict_list` = function(x, name) x[[name]] 39 | 40 | as.strict_list = function(x) { 41 | if (!is.list(x)) stop("'x' is not a list") 42 | class(x) = 'knitr_strict_list' 43 | x 44 | } 45 | -------------------------------------------------------------------------------- /R/rocco.R: -------------------------------------------------------------------------------- 1 | #' Knit R Markdown using the classic Docco style 2 | #' 3 | #' The classic Docco style is a two-column layout, with text in the left and 4 | #' code in the right column. 5 | #' 6 | #' The output HTML page supports resizing and hiding/showing the two columns. 7 | #' Move the cursor to the center of the page, and it will change to a 8 | #' bidirectional resize cursor; drag the cursor to resize the two columns. Press 9 | #' the key \code{t} to hide the code column (show the text column only), and 10 | #' press again to hide the text column (show code). 11 | #' @param input Path of the input R Markdown file. 12 | #' @param ... Arguments to be passed to \code{\link{knit2html}} 13 | #' @return An HTML file is written, and its name is returned. 14 | #' @author Weicheng Zhu and Yihui Xie 15 | #' @references The Docco package by Jeremy Ashkenas: 16 | #' \url{https://github.com/jashkenas/docco} 17 | #' @export 18 | #' @examples rocco_view=function(input) { 19 | #' owd = setwd(tempdir()); on.exit(setwd(owd)) 20 | #' if (!file.exists(input)) return() 21 | #' o=rocco(input, quiet=TRUE) 22 | #' if (interactive()) browseURL(o)} 23 | #' # knit these two vignettes using the docco style 24 | #' rocco_view(system.file('doc', 'docco-classic.Rmd', package = 'knitr')) 25 | #' rocco_view(system.file('doc', 'knit_expand.Rmd', package = 'knitr')) 26 | rocco = function(input, ...) { 27 | knit2html( 28 | input, ..., 29 | meta = list( 30 | css = c('@npm/@xiee/utils/css/docco-classic.min.css', '@prism-xcode'), 31 | js = c( 32 | '@npm/jquery@3.7.1/dist/jquery.min.js', 33 | '@npm/@xiee/utils/js/docco-classic.min.js,docco-resize.js', 34 | '@npm/@xiee/utils/js/center-img.min.js' 35 | ) 36 | ) 37 | ) 38 | } 39 | 40 | # the Docco linear style 41 | docco_linear = function(...) { 42 | knit2html(..., meta = list( 43 | css = c( 44 | 'https://ashkenas.com/docco/resources/linear/public/stylesheets/normalize.css', 45 | 'https://ashkenas.com/docco/resources/linear/docco.css', '@prism-xcode' 46 | ), 47 | js = '@npm/@xiee/utils/js/center-img.min.js', 48 | `header-includes` = '', 49 | `include-before` = '
', 50 | `include-after` = '
h
' 51 | )) 52 | } 53 | -------------------------------------------------------------------------------- /R/utils-string.R: -------------------------------------------------------------------------------- 1 | # replace parts of a string with new values; `pos` is a matrix of positions and 2 | # each row is a pair of [start, end] 3 | str_replace = function(x, pos, value) { 4 | if (length(x) != 1) stop("Only a character scalar is supported.") 5 | # extract parts of the string that are outside [start, end] 6 | m = rbind(pos[, 1] - 1, pos[, 2] + 1) 7 | m = matrix(c(1, m, nchar(x)), nrow = 2) 8 | y = substring(x, m[1, ], m[2, ]) 9 | paste(rbind(y, c(value, '')), collapse = '') 10 | } 11 | 12 | # insert a value after i-th character in the string x 13 | str_insert = function(x, i, value) { 14 | if (i <= 0) return(paste0(value, x)) 15 | n = nchar(x) 16 | if (n == 0 || i >= n) return(paste0(x, value)) 17 | paste0(substr(x, 1, i), value, substr(x, i + 1, n)) 18 | } 19 | 20 | # a simplified replacement for stringr::str_locate_all() that returns a list 21 | # having an element for every element of 'string'; every list element is an 22 | # integer matrix having a row per match, and two columns: 'start' and 'end'. 23 | str_locate = function(x, pattern, all = TRUE) { 24 | out = (if (all) gregexpr else regexpr)(pattern, x, perl = TRUE) 25 | if (all) lapply(out, location) else location(out) 26 | } 27 | 28 | location = function(x) { 29 | len = attr(x, 'match.length') 30 | if (length(x) == 1 && x == -1) x = integer() 31 | cbind(start = x, end = x + len - 1L) 32 | } 33 | 34 | # a replacement for stringr::str_extract_all() 35 | str_extract = function(x, pattern) { 36 | m = gregexpr(pattern, x, perl = TRUE) 37 | regmatches(x, m) 38 | } 39 | 40 | str_match = function(x, pattern) { 41 | # gregexec() was added in R 4.1.0; for lower versions of R, use fallback 42 | if (is.function(gregexec <- baseenv()[['gregexec']])) { 43 | m = gregexec(pattern, x, perl = TRUE) 44 | } else { 45 | x = unlist(str_extract(x, pattern)) 46 | m = regexec(pattern, x, perl = TRUE) 47 | } 48 | do.call(cbind, regmatches(x, m)) 49 | } 50 | -------------------------------------------------------------------------------- /R/utils-upload.R: -------------------------------------------------------------------------------- 1 | #' Upload an image to imgur.com 2 | #' 3 | #' This function is an alias to \code{xfun::upload_imgur()}. It is kept in 4 | #' \pkg{knitr} only for backward-compatibility reasons. You are recommended to 5 | #' use \code{xfun::upload_imgur()} directly instead. 6 | #' @param file,key,... See \code{xfun::\link[xfun]{upload_imgur}()}. 7 | #' @export 8 | #' @keywords internal 9 | imgur_upload = function(file, key = xfun::env_option('knitr.imgur.key'), ...) { 10 | xfun::upload_imgur(file, key, ..., include_xml = TRUE) 11 | } 12 | -------------------------------------------------------------------------------- /R/zzz.R: -------------------------------------------------------------------------------- 1 | has_rlang = FALSE 2 | 3 | .onLoad = function(lib, pkg) { 4 | register_vignette_engines(pkg) 5 | 6 | default_handlers <<- evaluate::new_output_handler() 7 | 8 | has_rlang <<- requireNamespace("rlang", quietly = TRUE) 9 | 10 | if (has_rlang) 11 | rlang_entrace_handler <<- list(error = function(e) rlang::entrace(e)) 12 | } 13 | -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | comment: false 2 | 3 | coverage: 4 | status: 5 | project: 6 | default: 7 | informational: true 8 | patch: 9 | default: 10 | informational: true 11 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | The source of the **knitr** website has been moved to https://github.com/yihui/yihui.org/tree/master/content/knitr 2 | -------------------------------------------------------------------------------- /inst/CITATION: -------------------------------------------------------------------------------- 1 | year = sub('.*(2[[:digit:]]{3})-.*', '\\1', meta[['Date/Publication']], perl = TRUE) 2 | vers = paste('R package version', meta$Version) 3 | if (length(year) == 0) year = format(Sys.Date(), '%Y') 4 | 5 | bibentry( 6 | 'manual', 7 | title = paste('knitr:', gsub('\\bR\\b', '{R}', meta$Title)), 8 | author = Filter(function(p) 'aut' %in% p$role, as.person(meta$Author)), 9 | year = year, 10 | note = vers, 11 | url = meta$URL 12 | ) 13 | 14 | bibentry( 15 | 'book', 16 | title = 'Dynamic Documents with {R} and knitr', 17 | author = 'Yihui Xie', 18 | publisher = 'Chapman and Hall/CRC', 19 | address = 'Boca Raton, Florida', 20 | year = '2015', 21 | edition = '2nd', 22 | note = 'ISBN 978-1498716963', 23 | url = meta$URL, 24 | textVersion = paste('Yihui Xie (2015)', 'Dynamic Documents with R and knitr.', 25 | '2nd edition. Chapman and Hall/CRC. ISBN 978-1498716963') 26 | ) 27 | 28 | bibentry( 29 | 'incollection', 30 | booktitle = 'Implementing Reproducible Computational Research', 31 | editor = 'Victoria Stodden and Friedrich Leisch and Roger D. Peng', 32 | title = 'knitr: A Comprehensive Tool for Reproducible Research in {R}', 33 | author = 'Yihui Xie', 34 | publisher = 'Chapman and Hall/CRC', 35 | year = '2014', 36 | note = 'ISBN 978-1466561595', 37 | textVersion = paste('Yihui Xie (2014)', 38 | 'knitr: A Comprehensive Tool for Reproducible Research in R.', 39 | 'In Victoria Stodden, Friedrich Leisch and Roger D. Peng, editors,', 40 | 'Implementing Reproducible Computational Research.', 41 | 'Chapman and Hall/CRC. ISBN 978-1466561595') 42 | ) 43 | -------------------------------------------------------------------------------- /inst/NEWS.Rd: -------------------------------------------------------------------------------- 1 | \name{NEWS} 2 | \title{News for Package 'knitr'} 3 | 4 | \section{CHANGES IN knitr VERSION 999.999}{ 5 | \itemize{ 6 | \item This NEWS file is only a placeholder. The version 999.999 does not really 7 | exist. Please read the NEWS on Github: \url{https://github.com/yihui/knitr/releases} 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /inst/bin/knit: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env Rscript 2 | 3 | local({ 4 | p = commandArgs(TRUE) 5 | if (length(p) == 0L || any(c('-h', '--help') %in% p)) { 6 | message('usage: knit input [input2 input3] [-n] [-o output output2 output3] 7 | -h, --help to print help messages 8 | -n, --no-convert do not convert tex to pdf, markdown to html, etc 9 | -o output filename(s) for knit()') 10 | q('no') 11 | } 12 | 13 | library(knitr) 14 | o = match('-o', p) 15 | if (is.na(o)) output = NA else { 16 | output = tail(p, length(p) - o) 17 | p = head(p, o - 1L) 18 | } 19 | nc = c('-n', '--no-convert') 20 | knit_fun = if (any(nc %in% p)) { 21 | p = setdiff(p, nc) 22 | knit 23 | } else { 24 | if (length(p) == 0L) stop('no input file provided') 25 | if (grepl('\\.(R|S)(nw|tex)$', p[1])) { 26 | function(x, ...) knit2pdf(x, ..., clean = TRUE) 27 | } else { 28 | if (grepl('\\.R(md|markdown)$', p[1])) knit2html else knit 29 | } 30 | } 31 | 32 | mapply(knit_fun, p, output = output, MoreArgs = list(envir = globalenv())) 33 | }) 34 | -------------------------------------------------------------------------------- /inst/examples/README.md: -------------------------------------------------------------------------------- 1 | # knitr-examples 2 | 3 | To compile the `knitr-graphics` example, look at the bottom of the file 4 | [`knitr-graphics.lyx`](knitr-graphics.lyx) for its dependencies. 5 | -------------------------------------------------------------------------------- /inst/examples/child/knitr-child-a.Rnw: -------------------------------------------------------------------------------- 1 | \section{Child via the \texttt{child} option} 2 | 3 | This chunk below is from the chunk option \texttt{child}. 4 | 5 | <>= 6 | 1+1 # child a 7 | @ 8 | -------------------------------------------------------------------------------- /inst/examples/child/knitr-child-b.Rnw: -------------------------------------------------------------------------------- 1 | \section{Another child via the \texttt{child} option} 2 | 3 | <>= 4 | 1+1 # child b 5 | @ 6 | -------------------------------------------------------------------------------- /inst/examples/child/knitr-child.Rmd: -------------------------------------------------------------------------------- 1 | Hi, there. I'm a child. 2 | 3 | ```{r test-child} 4 | options(digits = 4) 5 | 1+1 6 | dnorm(0) 7 | ``` 8 | -------------------------------------------------------------------------------- /inst/examples/child/knitr-child2.Rmd: -------------------------------------------------------------------------------- 1 | Hi, there. I'm another child. 2 | 3 | ```{r test-child2} 4 | x <- rnorm(n = 3) 5 | x 6 | ``` 7 | -------------------------------------------------------------------------------- /inst/examples/child/knitr-main.Rmd: -------------------------------------------------------------------------------- 1 | You can also use the `child` option to include child documents in markdown. 2 | 3 | ```{r test-main, child='knitr-child.Rmd'} 4 | ``` 5 | 6 | You can continue your main document below, of course. 7 | 8 | ```{r test-another} 9 | pmax(1:10, 5) 10 | ``` 11 | 12 | If you refer to a child document in a chunk, only the child document will be evaluated. 13 | Other code in the chunk will not be evaluated when you `render` the document. 14 | 15 | ```{r test-warning-option, include=FALSE} 16 | options(knitr.child.warning = FALSE) 17 | ``` 18 | 19 | ```{r test-warning, child='knitr-child2.Rmd'} 20 | x <- "this code is not evaluated" 21 | x 22 | ``` 23 | -------------------------------------------------------------------------------- /inst/examples/child/knitr-main.Rnw: -------------------------------------------------------------------------------- 1 | \documentclass{article} 2 | \usepackage{mathpazo} 3 | \begin{document} 4 | This main document has several children. 5 | 6 | <>= 7 | 1+1 8 | @ 9 | <>= 10 | @ 11 | 12 | <>= 13 | @ 14 | 15 | \end{document} 16 | -------------------------------------------------------------------------------- /inst/examples/child/knitr-main.md: -------------------------------------------------------------------------------- 1 | You can also use the `child` option to include child documents in markdown. 2 | 3 | 4 | Hi, there. I'm a child. 5 | 6 | 7 | ```r 8 | options(digits = 4) 9 | 1 + 1 10 | ``` 11 | 12 | ``` 13 | ## [1] 2 14 | ``` 15 | 16 | ```r 17 | dnorm(0) 18 | ``` 19 | 20 | ``` 21 | ## [1] 0.3989 22 | ``` 23 | 24 | You can continue your main document below, of course. 25 | 26 | 27 | ```r 28 | pmax(1:10, 5) 29 | ``` 30 | 31 | ``` 32 | ## [1] 5 5 5 5 5 6 7 8 9 10 33 | ``` 34 | -------------------------------------------------------------------------------- /inst/examples/child/knitr-parent.Rnw: -------------------------------------------------------------------------------- 1 | \section{Child can specify its parents} 2 | 3 | <>= 4 | set_parent('knitr-main.Rnw') 5 | @ 6 | 7 | My parent is \textsf{knitr-main.Rnw}. 8 | 9 | <>= 10 | 1+1 11 | @ 12 | 13 | I'm not a complete LaTeX document, but you can compile me nonetheless. I'll 14 | borrow the preamble from my parent. 15 | 16 | -------------------------------------------------------------------------------- /inst/examples/child/sub/knitr-child-c.Rnw: -------------------------------------------------------------------------------- 1 | \section{Child in a sub directory} 2 | 3 | <>= 4 | 1+1 # child d 5 | @ 6 | -------------------------------------------------------------------------------- /inst/examples/knit-all.R: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env Rscript 2 | 3 | if (!nzchar(Sys.which('lyx')) || system('lyx -version') != 0L) q() 4 | 5 | call_lyx = function(file) { 6 | res = sapply(sprintf('lyx -e %s %s', c('knitr', 'r', 'pdf2'), file), 7 | system, ignore.stdout = TRUE, USE.NAMES = FALSE) 8 | unlink(sub('\\.lyx$', '.R', file)) 9 | stopifnot(identical(res, integer(3L))) 10 | } 11 | 12 | for (i in list.files(pattern = '\\.lyx$')) { 13 | message(i) 14 | call_lyx(i) 15 | flush.console() 16 | } 17 | 18 | knit_script = normalizePath('../bin/knit', mustWork = TRUE) 19 | knit_cmd = function(file) { 20 | paste('Rscript', shQuote(knit_script), shQuote(file)) 21 | } 22 | test_cmd = function(cmd) { 23 | stopifnot(identical(system(cmd, ignore.stdout = TRUE), 0L)) 24 | } 25 | 26 | for (i in list.files(pattern = '\\.Rmd')) { 27 | message(i) 28 | cmd = if (i == 'knitr-minimal.Rmd') { 29 | sprintf("Rscript -e 'library(knitr);opts_knit$set(base.url=\"http://animation.r-forge.r-project.org/ideas/\");knit(\"%s\")'", i) 30 | } else knit_cmd(i) 31 | test_cmd(cmd) 32 | flush.console() 33 | } 34 | 35 | test_cmd(sprintf("Rscript -e 'library(knitr);spin(\"knitr-spin.R\", precious=TRUE)'")) 36 | 37 | setwd('child') 38 | for (i in c('knitr-main.Rnw', 'knitr-parent.Rnw')) { 39 | test_cmd(knit_cmd(i)) 40 | } 41 | unlink('*.tex') 42 | test_cmd(knit_cmd('knitr-main.Rmd')) 43 | setwd('..') 44 | 45 | file.remove('child/knitr-main.html') 46 | -------------------------------------------------------------------------------- /inst/examples/knitr-input-child.Rnw: -------------------------------------------------------------------------------- 1 | This chunk below is from the child document. 2 | 3 | <>= 4 | 1+1 5 | rnorm(5) 6 | plot(1) 7 | boxplot(1:10) 8 | str(mtcars) 9 | @ 10 | -------------------------------------------------------------------------------- /inst/examples/knitr-input.Rnw: -------------------------------------------------------------------------------- 1 | \documentclass{article} 2 | 3 | \begin{document} 4 | 5 | <>= 6 | options(width = 60) 7 | summary(iris) 8 | @ 9 | 10 | Let's see how to work with child documents in knitr. Below we input 11 | the file \textsf{knitr-input-child.Rnw}: 12 | 13 | <>= 14 | @ 15 | % Or alternatively, use knit_child('knitr-input-child.Rnw') in \Sexpr 16 | 17 | Done! 18 | 19 | \end{document} 20 | -------------------------------------------------------------------------------- /inst/examples/knitr-latex.Rtex: -------------------------------------------------------------------------------- 1 | See https://github.com/yihui/knitr-examples/blob/master/005-latex.Rtex 2 | -------------------------------------------------------------------------------- /inst/examples/knitr-manual.bib: -------------------------------------------------------------------------------- 1 | @inproceedings{leisch2002, 2 | title={Sweave: Dynamic Generation of Statistical Reports Using Literate Data Analysis}, 3 | author={Leisch, F.}, 4 | booktitle={COMPSTAT 2002 Proceedings in Computational Statistics}, 5 | number={69}, 6 | pages={575--580}, 7 | year={2002}, 8 | organization={Physica Verlag, Heidelberg} 9 | } 10 | 11 | @book{xie2013, 12 | title = {Dynamic Documents with {R} and knitr}, 13 | author = {Yihui Xie}, 14 | publisher = {Chapman and Hall/CRC}, 15 | address = {Boca Raton, Florida}, 16 | year = {2015}, 17 | edition = {2nd}, 18 | note = {ISBN 978-1498716963}, 19 | url = {https://yihui.org/knitr/} 20 | } 21 | -------------------------------------------------------------------------------- /inst/examples/knitr-minimal.Rmd: -------------------------------------------------------------------------------- 1 | # A Minimal Example for Markdown 2 | 3 | This is a minimal example of using **knitr** to produce an _HTML_ page from _Markdown_. 4 | 5 | ## R code chunks 6 | 7 | ```{r setup} 8 | # set global chunk options: images will be 7x5 inches 9 | knitr::opts_chunk$set(fig.width=7, fig.height=5) 10 | options(digits = 4) 11 | ``` 12 | 13 | Now we write some code chunks in this markdown file: 14 | 15 | ```{r computing} 16 | x <- 1+1 # a simple calculator 17 | set.seed(123) 18 | rnorm(5) # boring random numbers 19 | ``` 20 | 21 | We can also produce plots: 22 | 23 | ```{r graphics} 24 | par(mar = c(4, 4, .1, .1)) 25 | with(mtcars, { 26 | plot(mpg~hp, pch=20, col='darkgray') 27 | lines(lowess(hp, mpg)) 28 | }) 29 | ``` 30 | 31 | ## Inline code 32 | 33 | Inline R code is also supported, e.g. the value of `x` is `r x`, and 2 × π 34 | = `r 2*pi`. 35 | 36 | ## Math 37 | 38 | LaTeX math as usual: $f(\alpha, \beta) \propto x^{\alpha-1}(1-x)^{\beta-1}$. 39 | 40 | ## Misc 41 | 42 | You can indent code chunks so they can nest within other environments such as lists. 43 | 44 | 1. the area of a circle with radius x 45 | ```{r foo} 46 | pi * x^2 47 | ``` 48 | 2. OK, that is great 49 | 50 | To compile me, use 51 | 52 | ```{r compile, eval=FALSE} 53 | library(knitr) 54 | knit('knitr-minimal.Rmd') 55 | ``` 56 | 57 | ## Conclusion 58 | 59 | Markdown is super easy to write. Go to **knitr** [homepage](https://yihui.org/knitr/) for details. 60 | -------------------------------------------------------------------------------- /inst/examples/knitr-minimal.Rnw: -------------------------------------------------------------------------------- 1 | %% LyX 2.2.1 created this file. For more info, see http://www.lyx.org/. 2 | %% Do not edit unless you really know what you are doing. 3 | \documentclass{article} 4 | \usepackage[sc]{mathpazo} 5 | \usepackage[T1]{fontenc} 6 | \usepackage{geometry} 7 | \geometry{verbose,tmargin=2.5cm,bmargin=2.5cm,lmargin=2.5cm,rmargin=2.5cm} 8 | \setcounter{secnumdepth}{2} 9 | \setcounter{tocdepth}{2} 10 | \usepackage{url} 11 | \usepackage[unicode=true,pdfusetitle, 12 | bookmarks=true,bookmarksnumbered=true,bookmarksopen=true,bookmarksopenlevel=2, 13 | breaklinks=false,pdfborder={0 0 1},backref=false,colorlinks=false] 14 | {hyperref} 15 | \hypersetup{ 16 | pdfstartview={XYZ null null 1}} 17 | \usepackage{breakurl} 18 | \begin{document} 19 | <>= 20 | library(knitr) 21 | # set global chunk options 22 | opts_chunk$set(fig.path='figure/minimal-', fig.align='center', fig.show='hold') 23 | options(formatR.arrow=TRUE,width=90) 24 | @ 25 | 26 | \title{A Minimal Demo of knitr} 27 | 28 | \author{Yihui Xie} 29 | 30 | \maketitle 31 | You can test if \textbf{knitr} works with this minimal demo. OK, let's 32 | get started with some boring random numbers: 33 | 34 | <>= 35 | set.seed(1121) 36 | (x=rnorm(20)) 37 | mean(x);var(x) 38 | @ 39 | 40 | The first element of \texttt{x} is \Sexpr{x[1]}. Boring boxplots 41 | and histograms recorded by the PDF device: 42 | 43 | <>= 44 | ## two plots side by side (option fig.show='hold') 45 | par(mar=c(4,4,.1,.1),cex.lab=.95,cex.axis=.9,mgp=c(2,.7,0),tcl=-.3,las=1) 46 | boxplot(x) 47 | hist(x,main='') 48 | @ 49 | 50 | Do the above chunks work? You should be able to compile the \TeX{} 51 | document and get a PDF file like this one: \url{https://github.com/yihui/knitr/releases/download/doc/knitr-minimal.pdf}. 52 | The Rnw source of this document is at \url{https://github.com/yihui/knitr/blob/master/inst/examples/knitr-minimal.Rnw}. 53 | \end{document} 54 | -------------------------------------------------------------------------------- /inst/examples/knitr-minimal.Rrst: -------------------------------------------------------------------------------- 1 | See https://github.com/yihui/knitr-examples/blob/master/006-minimal.Rrst 2 | -------------------------------------------------------------------------------- /inst/examples/knitr-minimal.brew: -------------------------------------------------------------------------------- 1 | See https://github.com/yihui/knitr-examples/blob/master/004-minimal.brew 2 | -------------------------------------------------------------------------------- /inst/examples/knitr-minimal.md: -------------------------------------------------------------------------------- 1 | # A Minimal Example for Markdown 2 | 3 | This is a minimal example of using **knitr** to produce an _HTML_ page from _Markdown_. 4 | 5 | ## R code chunks 6 | 7 | 8 | ```r 9 | # set global chunk options: images will be 7x5 inches 10 | knitr::opts_chunk$set(fig.width = 7, fig.height = 5) 11 | options(digits = 4) 12 | ``` 13 | 14 | Now we write some code chunks in this markdown file: 15 | 16 | 17 | ```r 18 | x <- 1 + 1 # a simple calculator 19 | set.seed(123) 20 | rnorm(5) # boring random numbers 21 | ``` 22 | 23 | ``` 24 | ## [1] -0.56048 -0.23018 1.55871 0.07051 0.12929 25 | ``` 26 | 27 | We can also produce plots: 28 | 29 | 30 | ```r 31 | par(mar = c(4, 4, 0.1, 0.1)) 32 | with(mtcars, { 33 | plot(mpg ~ hp, pch = 20, col = "darkgray") 34 | lines(lowess(hp, mpg)) 35 | }) 36 | ``` 37 | 38 | ![plot of chunk graphics](http://animation.r-forge.r-project.org/ideas/figure/graphics-1.png) 39 | 40 | ## Inline code 41 | 42 | Inline R code is also supported, e.g. the value of `x` is 2, and 2 × π 43 | = 6.2832. 44 | 45 | ## Math 46 | 47 | LaTeX math as usual: $f(\alpha, \beta) \propto x^{\alpha-1}(1-x)^{\beta-1}$. 48 | 49 | ## Misc 50 | 51 | You can indent code chunks so they can nest within other environments such as lists. 52 | 53 | 1. the area of a circle with radius x 54 | 55 | ```r 56 | pi * x^2 57 | ``` 58 | 59 | ``` 60 | ## [1] 12.57 61 | ``` 62 | 2. OK, that is great 63 | 64 | To compile me, use 65 | 66 | 67 | ```r 68 | library(knitr) 69 | knit("knitr-minimal.Rmd") 70 | ``` 71 | 72 | ## Conclusion 73 | 74 | Markdown is super easy to write. Go to **knitr** [homepage](https://yihui.org/knitr) for details. 75 | -------------------------------------------------------------------------------- /inst/examples/knitr-spin.R: -------------------------------------------------------------------------------- 1 | #' This is a special R script which can be used to generate a report. You can 2 | #' write normal text in roxygen comments. 3 | #' 4 | #' First we set up some options (you do not have to do this): 5 | 6 | #+ setup, include=FALSE 7 | knitr::opts_chunk$set(collapse = TRUE) 8 | 9 | #' The report begins here. 10 | 11 | #+ test-a, cache=FALSE 12 | # boring examples as usual 13 | set.seed(123) 14 | x = rnorm(5) 15 | mean(x) 16 | 17 | #' You can use the special syntax {{code}} to embed inline expressions, e.g. 18 | {{mean(x) + 2}} 19 | #' is the mean of x plus 2. 20 | #' The code itself may contain braces, but these are not checked. Thus, 21 | #' perfectly valid (though very strange) R code such as `{{2 + 3}} - {{4 - 5}}` 22 | #' can lead to errors because `2 + 3}} - {{4 - 5` will be treated as inline code. 23 | #' 24 | #' Now we continue writing the report. We can draw plots as well. 25 | 26 | #+ test-b, fig.width=5, fig.height=5 27 | par(mar = c(4, 4, .1, .1)); plot(x) 28 | 29 | #' Actually you do not have to write chunk options, in which case knitr will use 30 | #' default options. For example, the code below has no options attached: 31 | 32 | var(x) 33 | quantile(x) 34 | 35 | #' And you can also write two chunks successively like this: 36 | 37 | #+ test-chisq5 38 | sum(x^2) # chi-square distribution with df 5 39 | #+ test-chisq4 40 | sum((x - mean(x))^2) # df is 4 now 41 | 42 | #' Done. Call spin('knitr-spin.R') to make silk from sow's ear now and knit a 43 | #' lovely purse. 44 | 45 | # /* you can write comments between /* and */ like C comments (the preceding # 46 | # is optional) 47 | Sys.sleep(60) 48 | # */ 49 | 50 | # /* there is no inline comment; you have to write block comments */ 51 | -------------------------------------------------------------------------------- /inst/examples/knitr-spin.Rmd: -------------------------------------------------------------------------------- 1 | This is a special R script which can be used to generate a report. You can 2 | write normal text in roxygen comments. 3 | 4 | First we set up some options (you do not have to do this): 5 | 6 | ```{r setup, include=FALSE} 7 | library(knitr) 8 | opts_chunk$set(fig.path = 'figure/silk-') 9 | ``` 10 | 11 | The report begins here. 12 | 13 | ```{r test-a, cache=FALSE} 14 | # boring examples as usual 15 | set.seed(123) 16 | x = rnorm(5) 17 | mean(x) 18 | ``` 19 | 20 | You can use the special syntax {{code}} to embed inline expressions, e.g. 21 | `r mean(x) + 2` 22 | is the mean of x plus 2. 23 | The code itself may contain braces, but these are not checked. Thus, 24 | perfectly valid (though very strange) R code such as `{{2 + 3}} - {{4 - 5}}` 25 | can lead to errors because `2 + 3}} - {{4 - 5` will be treated as inline code. 26 | 27 | Now we continue writing the report. We can draw plots as well. 28 | 29 | ```{r test-b, fig.width=5, fig.height=5} 30 | par(mar = c(4, 4, .1, .1)); plot(x) 31 | ``` 32 | 33 | Actually you do not have to write chunk options, in which case knitr will use 34 | default options. For example, the code below has no options attached: 35 | 36 | ```{r } 37 | var(x) 38 | quantile(x) 39 | ``` 40 | 41 | And you can also write two chunks successively like this: 42 | 43 | ```{r test-chisq5} 44 | sum(x^2) # chi-square distribution with df 5 45 | ``` 46 | ```{r test-chisq4} 47 | sum((x - mean(x))^2) # df is 4 now 48 | ``` 49 | 50 | Done. Call spin('knitr-spin.R') to make silk from sow's ear now and knit a 51 | lovely purse. 52 | -------------------------------------------------------------------------------- /inst/examples/knitr-twocolumn.Rnw: -------------------------------------------------------------------------------- 1 | %% LyX 2.2.1 created this file. For more info, see http://www.lyx.org/. 2 | %% Do not edit unless you really know what you are doing. 3 | \documentclass[twocolumn]{article} 4 | \usepackage[sc]{mathpazo} 5 | \usepackage[T1]{fontenc} 6 | \usepackage{geometry} 7 | \geometry{verbose,tmargin=3cm,bmargin=3cm,lmargin=3cm,rmargin=3cm} 8 | \setcounter{secnumdepth}{2} 9 | \setcounter{tocdepth}{2} 10 | \setlength{\parskip}{\bigskipamount} 11 | \setlength{\parindent}{0pt} 12 | \usepackage{url} 13 | \usepackage[unicode=true,pdfusetitle, 14 | bookmarks=true,bookmarksnumbered=true,bookmarksopen=true,bookmarksopenlevel=2, 15 | breaklinks=false,pdfborder={0 0 1},backref=false,colorlinks=false] 16 | {hyperref} 17 | \hypersetup{ 18 | pdfstartview={XYZ null null 1}} 19 | \usepackage{breakurl} 20 | 21 | \makeatletter 22 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands. 23 | \renewcommand{\textfraction}{0.05} 24 | \renewcommand{\topfraction}{0.8} 25 | \renewcommand{\bottomfraction}{0.8} 26 | \renewcommand{\floatpagefraction}{0.75} 27 | 28 | \makeatother 29 | 30 | \begin{document} 31 | <>= 32 | library(knitr) 33 | opts_chunk$set(fig.path='figure/twocolumn-', fig.align='center', fig.show='hold') 34 | render_listings() 35 | @ 36 | 37 | \title{Using knitr in A Two-column Document} 38 | 39 | \author{Yihui Xie} 40 | 41 | \maketitle 42 | We can use the \texttt{figure{*}} environment in \LaTeX{} so that 43 | figures can span over two columns. Because the output hooks use the 44 | \textbf{framed} package which does not work well with the \texttt{figure{*}} 45 | environment, we can either modify the output hooks or use other packages 46 | like \textbf{listings}. For example, 47 | 48 | <>= 49 | <> 50 | @ 51 | 52 | \begin{figure*} 53 | <>= 54 | x=rnorm(100) 55 | par(mar=c(4,4,.1,.1)) 56 | boxplot(x) 57 | hist(x,main='') 58 | @ 59 | 60 | \caption{Two plots spanning over two columns.} 61 | \end{figure*} 62 | 63 | The output PDF file will be like: \url{https://github.com/yihui/knitr/releases/download/doc/knitr-twocolumn.pdf}. 64 | The Rnw source of this document is at \url{https://github.com/yihui/knitr/blob/master/inst/examples/knitr-twocolumn.Rnw}. 65 | \end{document} 66 | -------------------------------------------------------------------------------- /inst/misc/R.css: -------------------------------------------------------------------------------- 1 | * { 2 | font-family: "Trebuchet MS", "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Arial, sans-serif; 3 | font-size: 14px; 4 | } 5 | body { 6 | padding: 0 5px; 7 | margin: 0 auto; 8 | width: 80%; 9 | max-width: 60em; /* 960px */ 10 | } 11 | 12 | h1, h2, h3, h4, h5, h6 { 13 | color: #666; 14 | } 15 | h1, h2 { 16 | text-align: center; 17 | } 18 | h1 { 19 | font-size: x-large; 20 | } 21 | h2, h3 { 22 | font-size: large; 23 | } 24 | h4, h6 { 25 | font-style: italic; 26 | } 27 | h3 { 28 | border-left: solid 5px #ddd; 29 | padding-left: 5px; 30 | font-variant: small-caps; 31 | } 32 | 33 | p img { 34 | display: block; 35 | margin: auto; 36 | } 37 | 38 | span, code, pre { 39 | font-family: Monaco, "Lucida Console", "Courier New", Courier, monospace; 40 | } 41 | span.acronym {} 42 | span.env { 43 | font-style: italic; 44 | } 45 | span.file {} 46 | span.option {} 47 | span.pkg { 48 | font-weight: bold; 49 | } 50 | span.samp{} 51 | 52 | dt, p code { 53 | background-color: #F7F7F7; 54 | } 55 | 56 | -------------------------------------------------------------------------------- /inst/misc/knitr-template.Rhtml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 10 | <!--rinline I(.knitr.title) --> 11 | 12 | 13 | 14 |

This report is automatically generated with the R 15 | package knitr 16 | (version ) 17 | .

18 | 19 | 21 | 22 |

The R session information (including the OS info, R version and all 23 | packages used):

24 | 25 | 29 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /inst/misc/knitr-template.Rmd: -------------------------------------------------------------------------------- 1 | `r if (exists('.knitr.title')) I(paste('#', .knitr.title, sep = ''))` 2 | 3 | `r if (exists('.knitr.author')) I(.knitr.author)` 4 | 5 | This report was automatically generated with the R package **knitr** 6 | (version `r packageVersion('knitr')`). 7 | 8 | ```{r %sCHUNK_LABEL_HERE} 9 | ``` 10 | 11 | The R session information (including the OS info, R version and all 12 | packages used): 13 | 14 | ```{r session-info, cache=FALSE} 15 | sessionInfo() 16 | Sys.time() 17 | ``` 18 | ```{r clean-up, include=FALSE} 19 | if (exists('.knitr.title')) rm(.knitr.author) 20 | if (exists('.knitr.author')) rm(.knitr.author) 21 | ``` 22 | -------------------------------------------------------------------------------- /inst/misc/knitr-template.Rnw: -------------------------------------------------------------------------------- 1 | \documentclass{article} 2 | \usepackage[sc]{mathpazo} 3 | \renewcommand{\sfdefault}{lmss} 4 | \renewcommand{\ttdefault}{lmtt} 5 | \usepackage[T1]{fontenc} 6 | \usepackage{geometry} 7 | \geometry{verbose,tmargin=2.5cm,bmargin=2.5cm,lmargin=2.5cm,rmargin=2.5cm} 8 | \setcounter{secnumdepth}{2} 9 | \setcounter{tocdepth}{2} 10 | \usepackage[unicode=true,pdfusetitle, 11 | bookmarks=true,bookmarksnumbered=true,bookmarksopen=true,bookmarksopenlevel=2, 12 | breaklinks=false,pdfborder={0 0 1},backref=false,colorlinks=false] 13 | {hyperref} 14 | \hypersetup{ 15 | pdfstartview={XYZ null null 1}} 16 | 17 | \makeatletter 18 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands. 19 | \renewcommand{\textfraction}{0.05} 20 | \renewcommand{\topfraction}{0.8} 21 | \renewcommand{\bottomfraction}{0.8} 22 | \renewcommand{\floatpagefraction}{0.75} 23 | 24 | \makeatother 25 | 26 | \begin{document} 27 | 28 | <>= 29 | options(width=90) 30 | knitr::opts_chunk$set(out.width = '.6\\linewidth') 31 | .knitr.title = if (exists('.knitr.title')) paste('\\title{', .knitr.title, '}', sep = '') else '' 32 | .knitr.author = if (nzchar(.knitr.title) && exists('.knitr.author')) { 33 | paste('\\author{', .knitr.author, '%\n', 34 | '\\thanks{This report is automatically generated with the R package \\textbf{knitr} 35 | (version ', packageVersion('knitr'), ').}}', sep = '') 36 | } else '' 37 | @ 38 | 39 | \Sexpr{.knitr.title} 40 | 41 | \Sexpr{.knitr.author} 42 | 43 | \Sexpr{if (nzchar(.knitr.title)) '\\maketitle'} 44 | The results below are generated from an R script. 45 | 46 | <<%sCHUNK_LABEL_HERE>>= 47 | @ 48 | 49 | The R session information (including the OS info, R version and all 50 | packages used): 51 | 52 | <>= 53 | sessionInfo() 54 | Sys.time() 55 | @ 56 | <>= 57 | rm(.knitr.author); rm(.knitr.author) 58 | @ 59 | 60 | \end{document} 61 | -------------------------------------------------------------------------------- /inst/misc/knitr.css: -------------------------------------------------------------------------------- 1 | .inline { 2 | background-color: #f7f7f7; 3 | border:solid 1px #B0B0B0; 4 | } 5 | .error { 6 | font-weight: bold; 7 | color: #FF0000; 8 | } 9 | .warning { 10 | font-weight: bold; 11 | } 12 | .message { 13 | font-style: italic; 14 | } 15 | .source, .output, .warning, .error, .message { 16 | padding: 0 1em; 17 | border:solid 1px #F7F7F7; 18 | } 19 | .source { 20 | background-color: #F7F7F7; 21 | } 22 | .left { 23 | text-align: left; 24 | } 25 | .right { 26 | text-align: right; 27 | } 28 | .center { 29 | text-align: center; 30 | } 31 | -------------------------------------------------------------------------------- /inst/misc/knitr.sty: -------------------------------------------------------------------------------- 1 | \usepackage{framed} 2 | \makeatletter 3 | \newenvironment{kframe}{% 4 | \def\at@end@of@kframe{}% 5 | \ifinner\ifhmode% 6 | \def\at@end@of@kframe{\end{minipage}}% 7 | \begin{minipage}{\columnwidth}% 8 | \fi\fi% 9 | \def\FrameCommand##1{\hskip\@totalleftmargin \hskip-\fboxsep 10 | \colorbox{shadecolor}{##1}\hskip-\fboxsep 11 | % There is no \\@totalrightmargin, so: 12 | \hskip-\linewidth \hskip-\@totalleftmargin \hskip\columnwidth}% 13 | \MakeFramed {\advance\hsize-\width 14 | \@totalleftmargin\z@ \linewidth\hsize 15 | \@setminipage}}% 16 | {\par\unskip\endMakeFramed% 17 | \at@end@of@kframe} 18 | \makeatother 19 | 20 | \definecolor{shadecolor}{rgb}{.97, .97, .97} 21 | \definecolor{messagecolor}{rgb}{0, 0, 0} 22 | \definecolor{warningcolor}{rgb}{1, 0, 1} 23 | \definecolor{errorcolor}{rgb}{1, 0, 0} 24 | \newenvironment{knitrout}{}{} % an empty environment to be redefined in TeX 25 | 26 | -------------------------------------------------------------------------------- /inst/misc/stitch-test.R: -------------------------------------------------------------------------------- 1 | ## title: A test script for the function stitch() 2 | ## author: Yihui Xie 3 | set.seed(1121) 4 | (x = rnorm(20)) 5 | mean(x);var(x) 6 | boxplot(x) 7 | hist(x, main = '') 8 | 9 | -------------------------------------------------------------------------------- /inst/misc/tikz2pdf.tex: -------------------------------------------------------------------------------- 1 | \documentclass[ 2 | %% TIKZ_CLASSOPTION %% 3 | ]{standalone} 4 | \usepackage{amsmath} 5 | \usetikzlibrary{matrix} 6 | %% EXTRA_TIKZ_PREAMBLE_CODE %% 7 | \begin{document} 8 | %% TIKZ_CODE %% 9 | \end{document} 10 | -------------------------------------------------------------------------------- /inst/misc/toggleR.js: -------------------------------------------------------------------------------- 1 | // toggle visibility of R source blocks in R Markdown output 2 | (d => { 3 | d.insertAdjacentHTML('beforeend',''); 4 | d.lastElementChild.onclick = (e) => { 5 | d.querySelectorAll('pre.r').forEach(el => { 6 | el.style.display = (el.style.display === 'none') ? 'block' : 'none'; 7 | }); 8 | }; 9 | })(document.body); 10 | -------------------------------------------------------------------------------- /inst/misc/vignette.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /inst/themes/acid.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #eeeeee; 3 | } 4 | .num { 5 | color: #800080; 6 | font-weight: bold; 7 | } 8 | .sng { 9 | color: #a68500; 10 | } 11 | .com { 12 | color: #ff8000; 13 | } 14 | .opt { 15 | color: #ff0080; 16 | font-weight: bold; 17 | } 18 | .def { 19 | color: #000000; 20 | } 21 | .kwa { 22 | color: #bb7977; 23 | font-weight: bold; 24 | } 25 | .kwb { 26 | color: #8080c0; 27 | font-weight: bold; 28 | } 29 | .kwc { 30 | color: #0080c0; 31 | } 32 | .kwd { 33 | color: #004466; 34 | } 35 | -------------------------------------------------------------------------------- /inst/themes/aiseered.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #600000; 3 | } 4 | .num { 5 | color: #88ddee; 6 | } 7 | .sng { 8 | color: #ffcc88; 9 | } 10 | .com { 11 | color: #ffffff; 12 | font-style: italic; 13 | } 14 | .opt { 15 | color: #ffcc33; 16 | } 17 | .def { 18 | color: #f08080; 19 | } 20 | .kwa { 21 | color: #eeff99; 22 | font-weight: bold; 23 | } 24 | .kwb { 25 | color: #88ffaa; 26 | } 27 | .kwc { 28 | color: #aa99ff; 29 | } 30 | .kwd { 31 | color: #f0b77f; 32 | } 33 | -------------------------------------------------------------------------------- /inst/themes/andes.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #0f0f0f; 3 | } 4 | .num { 5 | color: #dfaf87; 6 | } 7 | .sng { 8 | color: #ffff77; 9 | } 10 | .com { 11 | color: #33ff00; 12 | } 13 | .opt { 14 | color: #ff00cc; 15 | } 16 | .def { 17 | color: #f0f0f0; 18 | } 19 | .kwa { 20 | color: #66aaff; 21 | } 22 | .kwb { 23 | color: #66ff99; 24 | } 25 | .kwc { 26 | color: #cc9966; 27 | } 28 | .kwd { 29 | color: #ff99aa; 30 | } 31 | -------------------------------------------------------------------------------- /inst/themes/anotherdark.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #323232; 3 | } 4 | .num { 5 | color: #ffa0a0; 6 | } 7 | .sng { 8 | color: #ffa0a0; 9 | } 10 | .com { 11 | color: #ffa500; 12 | } 13 | .opt { 14 | color: #dedede; 15 | } 16 | .def { 17 | color: #dedede; 18 | } 19 | .kwa { 20 | color: #f0e68c; 21 | } 22 | .kwb { 23 | color: #bdb66b; 24 | } 25 | .kwc { 26 | color: #8b95f0; 27 | } 28 | .kwd { 29 | color: #f25252; 30 | } 31 | -------------------------------------------------------------------------------- /inst/themes/autumn.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #fff4e8; 3 | } 4 | .num { 5 | color: #00884c; 6 | } 7 | .sng { 8 | color: #00884c; 9 | } 10 | .com { 11 | color: #ff5050; 12 | } 13 | .opt { 14 | color: #404040; 15 | } 16 | .def { 17 | color: #404040; 18 | } 19 | .kwa { 20 | color: #80a030; 21 | } 22 | .kwb { 23 | color: #b06c58; 24 | } 25 | .kwc { 26 | color: #30a188; 27 | } 28 | .kwd { 29 | color: #990000; 30 | } 31 | -------------------------------------------------------------------------------- /inst/themes/baycomb.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #11121a; 3 | } 4 | .num { 5 | color: #4580b4; 6 | } 7 | .sng { 8 | color: #5c78f0; 9 | } 10 | .com { 11 | color: #349d58; 12 | } 13 | .opt { 14 | color: #b0b0b0; 15 | } 16 | .def { 17 | color: #a0b4e0; 18 | } 19 | .kwa { 20 | color: #fca8ad; 21 | } 22 | .kwb { 23 | color: #0490e8; 24 | font-weight: bold; 25 | } 26 | .kwc { 27 | color: #a9fcf7; 28 | } 29 | .kwd { 30 | color: #b4e09f; 31 | } 32 | -------------------------------------------------------------------------------- /inst/themes/bclear.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #ffffff; 3 | } 4 | .num { 5 | color: #1094a0; 6 | } 7 | .sng { 8 | color: #1094a0; 9 | } 10 | .com { 11 | color: #969696; 12 | } 13 | .opt { 14 | color: #323232; 15 | } 16 | .def { 17 | color: #323232; 18 | } 19 | .kwa { 20 | color: #3b6ac8; 21 | } 22 | .kwb { 23 | color: #a00050; 24 | } 25 | .kwc { 26 | color: #00a150; 27 | } 28 | .kwd { 29 | color: #c73a69; 30 | } 31 | -------------------------------------------------------------------------------- /inst/themes/biogoo.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #d6d6d6; 3 | } 4 | .num { 5 | color: #b85d00; 6 | } 7 | .sng { 8 | color: #d10000; 9 | } 10 | .com { 11 | color: #0000c3; 12 | } 13 | .opt { 14 | color: #000000; 15 | } 16 | .def { 17 | color: #000000; 18 | } 19 | .kwa { 20 | color: #00007f; 21 | } 22 | .kwb { 23 | color: #540054; 24 | font-weight: bold; 25 | } 26 | .kwc { 27 | color: #005400; 28 | } 29 | .kwd { 30 | color: #002a54; 31 | } 32 | -------------------------------------------------------------------------------- /inst/themes/bipolar.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #0f020a; 3 | } 4 | .num { 5 | color: #0083c9; 6 | } 7 | .sng { 8 | color: #eba236; 9 | } 10 | .com { 11 | color: #35d6e5; 12 | font-style: italic; 13 | } 14 | .opt { 15 | color: #e3d922; 16 | } 17 | .def { 18 | color: #d62b9a; 19 | } 20 | .kwa { 21 | color: #20c79d; 22 | font-weight: bold; 23 | } 24 | .kwb { 25 | color: #1d9617; 26 | font-weight: bold; 27 | } 28 | .kwc { 29 | color: #72d42c; 30 | font-weight: bold; 31 | } 32 | .kwd { 33 | color: #81e535; 34 | font-weight: bold; 35 | } 36 | -------------------------------------------------------------------------------- /inst/themes/blacknblue.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #000000; 3 | } 4 | .num { 5 | color: #cc3366; 6 | } 7 | .sng { 8 | color: #cfc631; 9 | } 10 | .com { 11 | color: #c47b6a; 12 | font-style: italic; 13 | } 14 | .opt { 15 | color: #ccc6c6; 16 | } 17 | .def { 18 | color: #22a0d6; 19 | } 20 | .kwa { 21 | color: #1ededc; 22 | font-weight: bold; 23 | } 24 | .kwb { 25 | color: #c06cf8; 26 | font-weight: bold; 27 | } 28 | .kwc { 29 | color: #00ff99; 30 | } 31 | .kwd { 32 | color: #1ceddc; 33 | } 34 | -------------------------------------------------------------------------------- /inst/themes/bluegreen.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #061A3E; 3 | } 4 | .num { 5 | color: #72A5E4; 6 | font-weight: bold; 7 | } 8 | .sng { 9 | color: #72A5E4; 10 | font-weight: bold; 11 | } 12 | .com { 13 | color: #DABEA2; 14 | font-style: italic; 15 | } 16 | .opt { 17 | color: #ffffff; 18 | } 19 | .def { 20 | color: #ffffff; 21 | } 22 | .kwa { 23 | color: #7E75B5; 24 | } 25 | .kwb { 26 | color: #A9EE8A; 27 | } 28 | .kwc { 29 | color: #b5768d; 30 | } 31 | .kwd { 32 | color: #76b57e; 33 | } 34 | -------------------------------------------------------------------------------- /inst/themes/breeze.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #005c70; 3 | } 4 | .num { 5 | color: #60ffff; 6 | } 7 | .sng { 8 | color: #60ffff; 9 | } 10 | .com { 11 | color: #c8d0d0; 12 | } 13 | .opt { 14 | color: #ffffff; 15 | } 16 | .def { 17 | color: #ffffff; 18 | } 19 | .kwa { 20 | color: #ffff80; 21 | } 22 | .kwb { 23 | color: #80ffa0; 24 | } 25 | .kwc { 26 | color: #7f7fff; 27 | } 28 | .kwd { 29 | color: #ff7fff; 30 | } 31 | -------------------------------------------------------------------------------- /inst/themes/bright.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #ffffff; 3 | } 4 | .num { 5 | color: #32ba06; 6 | } 7 | .sng { 8 | color: #1861a7; 9 | } 10 | .com { 11 | color: #006633; 12 | } 13 | .opt { 14 | color: #555555; 15 | } 16 | .def { 17 | color: #330066; 18 | } 19 | .kwa { 20 | color: #ff3030; 21 | } 22 | .kwb { 23 | color: #F48C23; 24 | } 25 | .kwc { 26 | color: #0000ff; 27 | } 28 | .kwd { 29 | color: #d11ced; 30 | } 31 | -------------------------------------------------------------------------------- /inst/themes/camo.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #232323; 3 | } 4 | .num { 5 | color: #d2691e; 6 | } 7 | .sng { 8 | color: #ffe4b5; 9 | } 10 | .com { 11 | color: #d2b48c; 12 | } 13 | .opt { 14 | color: #ffe4c4; 15 | } 16 | .def { 17 | color: #ffe4c4; 18 | } 19 | .kwa { 20 | color: #f0e68c; 21 | } 22 | .kwb { 23 | color: #cdc673; 24 | } 25 | .kwc { 26 | color: #c7f08b; 27 | } 28 | .kwd { 29 | color: #ffc7c4; 30 | } 31 | -------------------------------------------------------------------------------- /inst/themes/candy.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #000000; 3 | } 4 | .num { 5 | color: #90d0ff; 6 | } 7 | .sng { 8 | color: #90d0ff; 9 | } 10 | .com { 11 | color: #c0c0d0; 12 | font-style: italic; 13 | } 14 | .opt { 15 | color: #f0f0f8; 16 | } 17 | .def { 18 | color: #f0f0f8; 19 | } 20 | .kwa { 21 | color: #ffa0ff; 22 | } 23 | .kwb { 24 | color: #ffc864; 25 | } 26 | .kwc { 27 | color: #ffffa1; 28 | } 29 | .kwd { 30 | color: #ff5c33; 31 | } 32 | -------------------------------------------------------------------------------- /inst/themes/clarity.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #1F3055; 3 | } 4 | .num { 5 | color: #b3ee3a; 6 | } 7 | .sng { 8 | color: #cccccc; 9 | } 10 | .com { 11 | color: #9e9e9e; 12 | } 13 | .opt { 14 | color: #b2dfee; 15 | } 16 | .def { 17 | color: #b2dfee; 18 | } 19 | .kwa { 20 | color: #cd919e; 21 | } 22 | .kwb { 23 | color: #ff4400; 24 | } 25 | .kwc { 26 | color: #9ecc91; 27 | } 28 | .kwd { 29 | color: #edc1b2; 30 | } 31 | -------------------------------------------------------------------------------- /inst/themes/dante.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #000000; 3 | } 4 | .num { 5 | color: #ee0000; 6 | } 7 | .sng { 8 | color: #cd2626; 9 | } 10 | .com { 11 | color: #008b8b; 12 | } 13 | .opt { 14 | color: #cdaf96; 15 | } 16 | .def { 17 | color: #cdaf96; 18 | } 19 | .kwa { 20 | color: #cdad00; 21 | } 22 | .kwb { 23 | color: #66cd00; 24 | } 25 | .kwc { 26 | color: #cc0085; 27 | } 28 | .kwd { 29 | color: #cccccc; 30 | } 31 | -------------------------------------------------------------------------------- /inst/themes/darkblue.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #000040; 3 | } 4 | .num { 5 | color: #42cad9; 6 | } 7 | .sng { 8 | color: #ffa0a0; 9 | } 10 | .com { 11 | color: #80a0ff; 12 | } 13 | .opt { 14 | color: #bababa; 15 | } 16 | .def { 17 | color: #ffffff; 18 | } 19 | .kwa { 20 | color: #e2e825; 21 | } 22 | .kwb { 23 | color: #60ff60; 24 | } 25 | .kwc { 26 | color: #e88d25; 27 | } 28 | .kwd { 29 | color: #e825e2; 30 | font-weight: bold; 31 | } 32 | -------------------------------------------------------------------------------- /inst/themes/darkbone.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #000000; 3 | } 4 | .num { 5 | color: #d0e080; 6 | } 7 | .sng { 8 | color: #d0e080; 9 | } 10 | .com { 11 | color: #606080; 12 | } 13 | .opt { 14 | color: #cccccc; 15 | } 16 | .def { 17 | color: #a0a0c0; 18 | } 19 | .kwa { 20 | color: #8090f0; 21 | } 22 | .kwb { 23 | color: #e0e0ff; 24 | } 25 | .kwc { 26 | color: #7ff0a6; 27 | } 28 | .kwd { 29 | color: #9fbfaf; 30 | } 31 | -------------------------------------------------------------------------------- /inst/themes/darkness.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #000000; 3 | } 4 | .num { 5 | color: #619de7; 6 | } 7 | .sng { 8 | color: #abab00; 9 | font-weight: bold; 10 | } 11 | .com { 12 | color: #008888; 13 | } 14 | .opt { 15 | color: #ff00ff; 16 | } 17 | .def { 18 | color: #ffffff; 19 | } 20 | .kwa { 21 | color: #ffff00; 22 | font-weight: bold; 23 | } 24 | .kwb { 25 | color: #00ff00; 26 | } 27 | .kwc { 28 | color: #26e0e7; 29 | } 30 | .kwd { 31 | color: #f34627; 32 | } 33 | -------------------------------------------------------------------------------- /inst/themes/darkslategray.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #2f4f4f; 3 | } 4 | .num { 5 | color: #ff6347; 6 | } 7 | .sng { 8 | color: #7fffd4; 9 | } 10 | .com { 11 | color: #da70d6; 12 | } 13 | .opt { 14 | color: #f5deb3; 15 | } 16 | .def { 17 | color: #f5deb3; 18 | } 19 | .kwa { 20 | color: #4682b4; 21 | font-weight: bold; 22 | } 23 | .kwb { 24 | color: #98fb98; 25 | font-weight: bold; 26 | } 27 | .kwc { 28 | color: #b57847; 29 | } 30 | .kwd { 31 | color: #b3caf5; 32 | } 33 | -------------------------------------------------------------------------------- /inst/themes/darkspectrum.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #2A2A2A; 3 | } 4 | .num { 5 | color: #fce94f; 6 | } 7 | .sng { 8 | color: #fce94f; 9 | } 10 | .com { 11 | color: #8a8a8a; 12 | } 13 | .opt { 14 | color: #efefef; 15 | } 16 | .def { 17 | color: #efefef; 18 | } 19 | .kwa { 20 | color: #ffffff; 21 | font-weight: bold; 22 | } 23 | .kwb { 24 | color: #8ae234; 25 | font-weight: bold; 26 | } 27 | .kwc { 28 | color: #34e3e3; 29 | } 30 | .kwd { 31 | color: #efefef; 32 | } 33 | -------------------------------------------------------------------------------- /inst/themes/default.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #F5F5F5; 3 | } 4 | .num { 5 | color: #AF0F91; 6 | } 7 | .sng { 8 | color: #317ECC; 9 | } 10 | .com { 11 | color: #AD95AF; 12 | font-style: italic; 13 | } 14 | .opt { 15 | color: #000000; 16 | } 17 | .def { 18 | color: #585858; 19 | } 20 | .kwa { 21 | color: #295F94; 22 | font-weight: bold; 23 | } 24 | .kwb { 25 | color: #B05A65; 26 | } 27 | .kwc { 28 | color: #55aa55; 29 | } 30 | .kwd { 31 | color: #BC5A65; 32 | font-weight: bold; 33 | } 34 | -------------------------------------------------------------------------------- /inst/themes/denim.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #000038; 3 | } 4 | .num { 5 | color: #33FF33; 6 | } 7 | .sng { 8 | color: #CCCC99; 9 | } 10 | .com { 11 | color: #999999; 12 | } 13 | .opt { 14 | color: #FFFFFF; 15 | } 16 | .def { 17 | color: #FFFFFF; 18 | } 19 | .kwa { 20 | color: #FFFFCC; 21 | } 22 | .kwb { 23 | color: #33FF99; 24 | } 25 | .kwc { 26 | color: #33FF99; 27 | } 28 | .kwd { 29 | color: #9966cc; 30 | } 31 | -------------------------------------------------------------------------------- /inst/themes/dusk.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #1f3048; 3 | } 4 | .num { 5 | color: #cdb7b5; 6 | } 7 | .sng { 8 | color: #9ac0cd; 9 | } 10 | .com { 11 | color: #708090; 12 | } 13 | .opt { 14 | color: #fffff0; 15 | } 16 | .def { 17 | color: #fffff0; 18 | } 19 | .kwa { 20 | color: #f0e68c; 21 | } 22 | .kwb { 23 | color: #ffdead; 24 | } 25 | .kwc { 26 | color: #8bf0b3; 27 | } 28 | .kwd { 29 | color: #8bf0e6; 30 | } 31 | -------------------------------------------------------------------------------- /inst/themes/earendel.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #ffffff; 3 | } 4 | .num { 5 | color: #a8660d; 6 | } 7 | .sng { 8 | color: #a8660d; 9 | } 10 | .com { 11 | color: #558817; 12 | } 13 | .opt { 14 | color: #000000; 15 | } 16 | .def { 17 | color: #000000; 18 | } 19 | .kwa { 20 | color: #2239a8; 21 | font-weight: bold; 22 | } 23 | .kwb { 24 | color: #8c1d69; 25 | font-weight: bold; 26 | } 27 | .kwc { 28 | color: #a89222; 29 | font-weight: bold; 30 | } 31 | .kwd { 32 | color: #a8227b; 33 | } 34 | -------------------------------------------------------------------------------- /inst/themes/easter.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #fff9b9; 3 | } 4 | .num { 5 | color: #e11a70; 6 | } 7 | .sng { 8 | color: #ca4be3; 9 | } 10 | .com { 11 | color: #1ea411; 12 | font-style: italic; 13 | } 14 | .opt { 15 | color: #fa4700; 16 | } 17 | .def { 18 | color: #2C7B34; 19 | } 20 | .kwa { 21 | color: #1d45d6; 22 | font-weight: bold; 23 | } 24 | .kwb { 25 | color: #ed0f55; 26 | font-weight: bold; 27 | } 28 | .kwc { 29 | color: #26aae7; 30 | font-weight: bold; 31 | } 32 | .kwd { 33 | color: #1d45d6; 34 | } 35 | -------------------------------------------------------------------------------- /inst/themes/edit-anjuta.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #ffffff; 3 | } 4 | .num { 5 | color: #008800; 6 | } 7 | .sng { 8 | color: #ddbb00; 9 | } 10 | .com { 11 | color: #ff0000; 12 | font-style: italic; 13 | } 14 | .opt { 15 | color: #000000; 16 | } 17 | .def { 18 | color: #000000; 19 | } 20 | .kwa { 21 | color: #000080; 22 | font-weight: bold; 23 | } 24 | .kwb { 25 | color: #000080; 26 | } 27 | .kwc { 28 | color: #0000ff; 29 | } 30 | .kwd { 31 | color: #000000; 32 | } 33 | -------------------------------------------------------------------------------- /inst/themes/edit-eclipse.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #ffffff; 3 | } 4 | .num { 5 | color: #000000; 6 | } 7 | .sng { 8 | color: #0000ff; 9 | } 10 | .com { 11 | color: #717ab3; 12 | } 13 | .opt { 14 | color: #000000; 15 | } 16 | .def { 17 | color: #000000; 18 | } 19 | .kwa { 20 | color: #7f0055; 21 | font-weight: bold; 22 | } 23 | .kwb { 24 | color: #7f0055; 25 | font-weight: bold; 26 | } 27 | .kwc { 28 | color: #7f0055; 29 | font-weight: bold; 30 | } 31 | .kwd { 32 | color: #000000; 33 | } 34 | -------------------------------------------------------------------------------- /inst/themes/edit-emacs.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #ffffff; 3 | } 4 | .num { 5 | color: #000000; 6 | } 7 | .sng { 8 | color: #bd8d8b; 9 | } 10 | .com { 11 | color: #ac2020; 12 | font-style: italic; 13 | } 14 | .opt { 15 | color: #000000; 16 | } 17 | .def { 18 | color: #000000; 19 | } 20 | .kwa { 21 | color: #9c20ee; 22 | font-weight: bold; 23 | } 24 | .kwb { 25 | color: #208920; 26 | } 27 | .kwc { 28 | color: #0000ff; 29 | } 30 | .kwd { 31 | color: #000000; 32 | } 33 | -------------------------------------------------------------------------------- /inst/themes/edit-flashdevelop.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #ffffff; 3 | } 4 | .num { 5 | color: #0000ff; 6 | font-weight: bold; 7 | } 8 | .sng { 9 | color: #a31515; 10 | } 11 | .com { 12 | color: #606060; 13 | } 14 | .opt { 15 | color: #000000; 16 | } 17 | .def { 18 | color: #000000; 19 | } 20 | .kwa { 21 | color: #0000ff; 22 | } 23 | .kwb { 24 | color: #0000ff; 25 | } 26 | .kwc { 27 | color: #2b91af; 28 | } 29 | .kwd { 30 | color: #2b91af; 31 | } 32 | -------------------------------------------------------------------------------- /inst/themes/edit-gedit.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #ffffff; 3 | } 4 | .num { 5 | color: #FF00FF; 6 | } 7 | .sng { 8 | color: #FF00FF; 9 | } 10 | .com { 11 | color: #003CFF; 12 | } 13 | .opt { 14 | color: #3A3935; 15 | } 16 | .def { 17 | color: #3A3935; 18 | } 19 | .kwa { 20 | color: #A52A35; 21 | } 22 | .kwb { 23 | color: #2E8B57; 24 | } 25 | .kwc { 26 | color: #572e8c; 27 | } 28 | .kwd { 29 | color: #3A3935; 30 | font-weight: bold; 31 | } 32 | -------------------------------------------------------------------------------- /inst/themes/edit-jedit.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #ffffff; 3 | } 4 | .num { 5 | color: #ff0000; 6 | } 7 | .sng { 8 | color: #ff00cc; 9 | } 10 | .com { 11 | color: #cc0000; 12 | } 13 | .opt { 14 | color: #000000; 15 | font-weight: bold; 16 | } 17 | .def { 18 | color: #000000; 19 | } 20 | .kwa { 21 | color: #009966; 22 | font-weight: bold; 23 | } 24 | .kwb { 25 | color: #009966; 26 | font-weight: bold; 27 | } 28 | .kwc { 29 | color: #0099ff; 30 | } 31 | .kwd { 32 | color: #9966ff; 33 | } 34 | -------------------------------------------------------------------------------- /inst/themes/edit-kwrite.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #E0EAEE; 3 | } 4 | .num { 5 | color: #B07E00; 6 | } 7 | .sng { 8 | color: #BF0303; 9 | } 10 | .com { 11 | color: #838183; 12 | font-style: italic; 13 | } 14 | .opt { 15 | color: #000000; 16 | } 17 | .def { 18 | color: #000000; 19 | } 20 | .kwa { 21 | color: #000000; 22 | font-weight: bold; 23 | } 24 | .kwb { 25 | color: #0057AE; 26 | } 27 | .kwc { 28 | color: #000000; 29 | font-weight: bold; 30 | } 31 | .kwd { 32 | color: #010181; 33 | } 34 | -------------------------------------------------------------------------------- /inst/themes/edit-matlab.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #ffffff; 3 | } 4 | .num { 5 | color: #000000; 6 | } 7 | .sng { 8 | color: #800000; 9 | } 10 | .com { 11 | color: #000000; 12 | } 13 | .opt { 14 | color: #000000; 15 | } 16 | .def { 17 | color: #000000; 18 | } 19 | .kwa { 20 | color: #0000ff; 21 | } 22 | .kwb { 23 | color: #000000; 24 | } 25 | .kwc { 26 | color: #0000ff; 27 | } 28 | .kwd { 29 | color: #000000; 30 | } 31 | -------------------------------------------------------------------------------- /inst/themes/edit-msvs2008.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #ffffff; 3 | } 4 | .num { 5 | color: #000000; 6 | } 7 | .sng { 8 | color: #a31515; 9 | } 10 | .com { 11 | color: #008000; 12 | } 13 | .opt { 14 | color: #000000; 15 | } 16 | .def { 17 | color: #000000; 18 | } 19 | .kwa { 20 | color: #0000ff; 21 | } 22 | .kwb { 23 | color: #0000ff; 24 | } 25 | .kwc { 26 | color: #2b91af; 27 | } 28 | .kwd { 29 | color: #000000; 30 | } 31 | -------------------------------------------------------------------------------- /inst/themes/edit-nedit.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #ffffff; 3 | } 4 | .num { 5 | color: #006400; 6 | } 7 | .sng { 8 | color: #006400; 9 | } 10 | .com { 11 | color: #000000; 12 | font-style: italic; 13 | } 14 | .opt { 15 | color: #000000; 16 | font-weight: bold; 17 | } 18 | .def { 19 | color: #000000; 20 | } 21 | .kwa { 22 | color: #000000; 23 | font-weight: bold; 24 | } 25 | .kwb { 26 | color: #a52a2a; 27 | font-weight: bold; 28 | } 29 | .kwc { 30 | color: #dda0dd; 31 | font-weight: bold; 32 | } 33 | .kwd { 34 | color: #000000; 35 | } 36 | -------------------------------------------------------------------------------- /inst/themes/edit-vim-dark.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #000000; 3 | } 4 | .num { 5 | color: #ff0000; 6 | } 7 | .sng { 8 | color: #ff0000; 9 | } 10 | .com { 11 | color: #0000ff; 12 | } 13 | .opt { 14 | color: #ffffff; 15 | } 16 | .def { 17 | color: #ffffff; 18 | } 19 | .kwa { 20 | color: #B26818; 21 | } 22 | .kwb { 23 | color: #00ff00; 24 | } 25 | .kwc { 26 | color: #B26818; 27 | } 28 | .kwd { 29 | color: #ffffff; 30 | } 31 | -------------------------------------------------------------------------------- /inst/themes/edit-vim.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #ffffff; 3 | } 4 | .num { 5 | color: #ff0000; 6 | } 7 | .sng { 8 | color: #ff0000; 9 | } 10 | .com { 11 | color: #0000ff; 12 | } 13 | .opt { 14 | color: #000000; 15 | } 16 | .def { 17 | color: #000000; 18 | } 19 | .kwa { 20 | color: #B26818; 21 | } 22 | .kwb { 23 | color: #00ff00; 24 | } 25 | .kwc { 26 | color: #B26818; 27 | } 28 | .kwd { 29 | color: #000000; 30 | } 31 | -------------------------------------------------------------------------------- /inst/themes/edit-xcode.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #ffffff; 3 | } 4 | .num { 5 | color: #2300ff; 6 | } 7 | .sng { 8 | color: #c00000; 9 | } 10 | .com { 11 | color: #007f1c; 12 | } 13 | .opt { 14 | color: #000000; 15 | } 16 | .def { 17 | color: #000000; 18 | } 19 | .kwa { 20 | color: #8f0055; 21 | } 22 | .kwb { 23 | color: #8f0055; 24 | } 25 | .kwc { 26 | color: #8f0055; 27 | } 28 | .kwd { 29 | color: #000000; 30 | } 31 | -------------------------------------------------------------------------------- /inst/themes/ekvoli.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #001535; 3 | } 4 | .num { 5 | color: #87c6f0; 6 | font-style: italic; 7 | } 8 | .sng { 9 | color: #87c6f0; 10 | font-style: italic; 11 | } 12 | .com { 13 | color: #9590d5; 14 | font-style: italic; 15 | } 16 | .opt { 17 | color: #dedede; 18 | } 19 | .def { 20 | color: #dedede; 21 | } 22 | .kwa { 23 | color: #ffffff; 24 | font-weight: bold; 25 | } 26 | .kwb { 27 | color: #90bfd0; 28 | } 29 | .kwc { 30 | color: #9fd190; 31 | } 32 | .kwd { 33 | color: #d1909e; 34 | } 35 | -------------------------------------------------------------------------------- /inst/themes/fine_blue.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #f8f8f8; 3 | } 4 | .num { 5 | color: #2020ff; 6 | } 7 | .sng { 8 | color: #2020ff; 9 | } 10 | .com { 11 | color: #ff00c0; 12 | font-style: italic; 13 | } 14 | .opt { 15 | color: #404048; 16 | } 17 | .def { 18 | color: #404048; 19 | } 20 | .kwa { 21 | color: #008858; 22 | font-weight: bold; 23 | } 24 | .kwb { 25 | color: #7040ff; 26 | font-weight: bold; 27 | } 28 | .kwc { 29 | color: #87002f; 30 | font-weight: bold; 31 | } 32 | .kwd { 33 | color: #404048; 34 | font-weight: bold; 35 | } 36 | -------------------------------------------------------------------------------- /inst/themes/freya.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #2a2a2a; 3 | } 4 | .num { 5 | color: #afe091; 6 | } 7 | .sng { 8 | color: #afe091; 9 | } 10 | .com { 11 | color: #c2b680; 12 | } 13 | .opt { 14 | color: #dcdccc; 15 | } 16 | .def { 17 | color: #dcdccc; 18 | } 19 | .kwa { 20 | color: #e0af91; 21 | font-weight: bold; 22 | } 23 | .kwb { 24 | color: #dabfa5; 25 | font-weight: bold; 26 | } 27 | .kwc { 28 | color: #d792e0; 29 | } 30 | .kwd { 31 | color: #a6e1ff; 32 | } 33 | -------------------------------------------------------------------------------- /inst/themes/fruit.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #f8f8f8; 3 | } 4 | .num { 5 | color: #8016ff; 6 | } 7 | .sng { 8 | color: #ff6633; 9 | } 10 | .com { 11 | color: #ff4080; 12 | } 13 | .opt { 14 | color: #404040; 15 | } 16 | .def { 17 | color: #404040; 18 | } 19 | .kwa { 20 | color: #f030d0; 21 | } 22 | .kwb { 23 | color: #0070e6; 24 | } 25 | .kwc { 26 | color: #30f050; 27 | } 28 | .kwd { 29 | color: #b030f0; 30 | } 31 | -------------------------------------------------------------------------------- /inst/themes/golden.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #000000; 3 | } 4 | .num { 5 | color: #ffffff; 6 | } 7 | .sng { 8 | color: #ff0000; 9 | } 10 | .com { 11 | color: #978345; 12 | font-style: italic; 13 | } 14 | .opt { 15 | color: #ababab; 16 | } 17 | .def { 18 | color: #ddbb00; 19 | } 20 | .kwa { 21 | color: #ffed8a; 22 | font-weight: bold; 23 | } 24 | .kwb { 25 | color: #ffed8a; 26 | } 27 | .kwc { 28 | color: #dedede; 29 | font-weight: bold; 30 | } 31 | .kwd { 32 | color: #ddbb00; 33 | font-weight: bold; 34 | } 35 | -------------------------------------------------------------------------------- /inst/themes/greenlcd.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #003000; 3 | } 4 | .num { 5 | color: #3399cc; 6 | } 7 | .sng { 8 | color: #dfdfdf; 9 | } 10 | .com { 11 | color: #888888; 12 | font-style: italic; 13 | } 14 | .opt { 15 | color: #2fe7a9; 16 | } 17 | .def { 18 | color: #00bb00; 19 | } 20 | .kwa { 21 | color: #00ed00; 22 | font-weight: bold; 23 | } 24 | .kwb { 25 | color: #00ed00; 26 | } 27 | .kwc { 28 | color: #beef13; 29 | } 30 | .kwd { 31 | color: #c0ff73; 32 | } 33 | -------------------------------------------------------------------------------- /inst/themes/greyscale0.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #ffffff; 3 | } 4 | .num { 5 | color: #333333; 6 | } 7 | .sng { 8 | color: #333333; 9 | } 10 | .com { 11 | font-style: italic; 12 | color: #4D4D4D; 13 | } 14 | .opt { 15 | color: #1A1A1A; 16 | } 17 | .def { 18 | color: #1A1A1A; 19 | } 20 | .kwa { 21 | color: #1A1A1A; 22 | } 23 | .kwb { 24 | color: #1A1A1A; 25 | } 26 | .kwc { 27 | color: #333333; 28 | } 29 | .kwd { 30 | font-weight: bold; 31 | color: #1A1A1A; 32 | } 33 | -------------------------------------------------------------------------------- /inst/themes/greyscale1.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #ffffff; 3 | } 4 | .num { 5 | color: #4D4D4D; 6 | } 7 | .sng { 8 | color: #4D4D4D; 9 | } 10 | .com { 11 | font-style: italic; 12 | color: #808080; 13 | } 14 | .opt { 15 | color: #1A1A1A; 16 | } 17 | .def { 18 | color: #1A1A1A; 19 | } 20 | .kwa { 21 | color: #1A1A1A; 22 | } 23 | .kwb { 24 | color: #1A1A1A; 25 | } 26 | .kwc { 27 | color: #4D4D4D; 28 | } 29 | .kwd { 30 | font-weight: bold; 31 | color: #1A1A1A; 32 | } 33 | -------------------------------------------------------------------------------- /inst/themes/greyscale2.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #ffffff; 3 | } 4 | .num { 5 | color: #666666; 6 | } 7 | .sng { 8 | color: #666666; 9 | } 10 | .com { 11 | font-style: italic; 12 | color: #B3B3B3; 13 | } 14 | .opt { 15 | color: #1A1A1A; 16 | } 17 | .def { 18 | color: #1A1A1A; 19 | } 20 | .kwa { 21 | color: #1A1A1A; 22 | } 23 | .kwb { 24 | color: #1A1A1A; 25 | } 26 | .kwc { 27 | color: #666666; 28 | } 29 | .kwd { 30 | font-weight: bold; 31 | color: #1A1A1A; 32 | } 33 | -------------------------------------------------------------------------------- /inst/themes/kellys.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #2a2b2f; 3 | } 4 | .num { 5 | color: #d1c79e; 6 | } 7 | .sng { 8 | color: #d1c79e; 9 | } 10 | .com { 11 | color: #67686b; 12 | } 13 | .opt { 14 | color: #e1e0e5; 15 | } 16 | .def { 17 | color: #e1e0e5; 18 | } 19 | .kwa { 20 | color: #62acce; 21 | font-weight: bold; 22 | } 23 | .kwb { 24 | color: #e6ac32; 25 | } 26 | .kwc { 27 | color: #cf8563; 28 | } 29 | .kwd { 30 | color: #bb63cf; 31 | } 32 | -------------------------------------------------------------------------------- /inst/themes/leo.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #000000; 3 | } 4 | .num { 5 | color: #ff875f; 6 | } 7 | .sng { 8 | color: #ffd7d7; 9 | } 10 | .com { 11 | color: #a8a8a8; 12 | font-style: italic; 13 | } 14 | .opt { 15 | color: #ffffff; 16 | } 17 | .def { 18 | color: #ffffff; 19 | } 20 | .kwa { 21 | color: #00d700; 22 | } 23 | .kwb { 24 | color: #5fafff; 25 | } 26 | .kwc { 27 | color: #006bd6; 28 | } 29 | .kwd { 30 | color: #d600d6; 31 | } 32 | -------------------------------------------------------------------------------- /inst/themes/lucretia.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #001C42; 3 | } 4 | .num { 5 | color: #63759C; 6 | } 7 | .sng { 8 | color: #E7F3B5; 9 | } 10 | .com { 11 | color: #944D39; 12 | } 13 | .opt { 14 | color: #6A7969; 15 | } 16 | .def { 17 | color: #de9d7c; 18 | } 19 | .kwa { 20 | color: #907fd4; 21 | } 22 | .kwb { 23 | color: #29a655; 24 | } 25 | .kwc { 26 | color: #427142; 27 | } 28 | .kwd { 29 | color: #A59A39; 30 | } 31 | -------------------------------------------------------------------------------- /inst/themes/manxome.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #000000; 3 | } 4 | .num { 5 | color: #00ffff; 6 | } 7 | .sng { 8 | color: #00ffff; 9 | } 10 | .com { 11 | color: #00ff00; 12 | } 13 | .opt { 14 | color: #ffff00; 15 | } 16 | .def { 17 | color: #cccccc; 18 | } 19 | .kwa { 20 | color: #00aaaa; 21 | } 22 | .kwb { 23 | color: #f70000; 24 | } 25 | .kwc { 26 | color: #5500ab; 27 | } 28 | .kwd { 29 | color: #00aaaa; 30 | } 31 | -------------------------------------------------------------------------------- /inst/themes/maroloccio.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #1a202a; 3 | } 4 | .num { 5 | color: #8b8b00; 6 | } 7 | .sng { 8 | color: #5B5BD0; 9 | } 10 | .com { 11 | color: #006666; 12 | } 13 | .opt { 14 | color: #8b9aaa; 15 | } 16 | .def { 17 | color: #8b9aaa; 18 | } 19 | .kwa { 20 | color: #9966cc; 21 | } 22 | .kwb { 23 | color: #ffcc00; 24 | } 25 | .kwc { 26 | color: #cc6666; 27 | } 28 | .kwd { 29 | color: #99cc66; 30 | } 31 | -------------------------------------------------------------------------------- /inst/themes/matrix.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #000000; 3 | } 4 | .num { 5 | color: #55ff55; 6 | } 7 | .sng { 8 | color: #ccff33; 9 | } 10 | .com { 11 | color: #226622; 12 | } 13 | .opt { 14 | color: #44cc44; 15 | } 16 | .def { 17 | color: #44cc44; 18 | } 19 | .kwa { 20 | color: #55ff55; 21 | font-weight: bold; 22 | } 23 | .kwb { 24 | color: #aaff54; 25 | font-weight: bold; 26 | } 27 | .kwc { 28 | color: #48d990; 29 | } 30 | .kwd { 31 | color: #54ffaa; 32 | } 33 | -------------------------------------------------------------------------------- /inst/themes/moe.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #f6f6f6; 3 | } 4 | .num { 5 | color: #880022; 6 | } 7 | .sng { 8 | color: #aa4400; 9 | } 10 | .com { 11 | color: #ff8800; 12 | } 13 | .opt { 14 | color: #000000; 15 | font-weight: bold; 16 | } 17 | .def { 18 | color: #000000; 19 | } 20 | .kwa { 21 | color: #661111; 22 | font-weight: bold; 23 | } 24 | .kwb { 25 | color: #000066; 26 | font-weight: bold; 27 | } 28 | .kwc { 29 | color: #000066; 30 | } 31 | .kwd { 32 | color: #004466; 33 | } 34 | -------------------------------------------------------------------------------- /inst/themes/molokai.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #272822; 3 | } 4 | .num { 5 | color: #AE81FF; 6 | } 7 | .sng { 8 | color: #E6DB74; 9 | } 10 | .com { 11 | color: #75715E; 12 | } 13 | .opt { 14 | color: #F8F8F2; 15 | } 16 | .def { 17 | color: #F8F8F2; 18 | } 19 | .kwa { 20 | color: #F92672; 21 | font-weight: bold; 22 | } 23 | .kwb { 24 | color: #66D9EF; 25 | } 26 | .kwc { 27 | color: #95f067; 28 | } 29 | .kwd { 30 | color: #25faac; 31 | } 32 | -------------------------------------------------------------------------------- /inst/themes/moria.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #202020; 3 | } 4 | .num { 5 | color: #87df71; 6 | } 7 | .sng { 8 | color: #87df71; 9 | } 10 | .com { 11 | color: #d0d0a0; 12 | } 13 | .opt { 14 | color: #d0d0d0; 15 | } 16 | .def { 17 | color: #d0d0d0; 18 | } 19 | .kwa { 20 | color: #7ec0ee; 21 | font-weight: bold; 22 | } 23 | .kwb { 24 | color: #f09479; 25 | font-weight: bold; 26 | } 27 | .kwc { 28 | color: #87ed7e; 29 | } 30 | .kwd { 31 | color: #e47eed; 32 | } 33 | -------------------------------------------------------------------------------- /inst/themes/navajo-night.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #35536f; 3 | } 4 | .num { 5 | color: #3fffa7; 6 | } 7 | .sng { 8 | color: #3fffa7; 9 | } 10 | .com { 11 | color: #e7e77f; 12 | } 13 | .opt { 14 | color: #ffffff; 15 | } 16 | .def { 17 | color: #ffffff; 18 | } 19 | .kwa { 20 | color: #5ad5d5; 21 | font-weight: bold; 22 | } 23 | .kwb { 24 | color: #d174a8; 25 | font-weight: bold; 26 | } 27 | .kwc { 28 | color: #98d65a; 29 | font-weight: bold; 30 | } 31 | .kwd { 32 | color: #ffffff; 33 | font-weight: bold; 34 | } 35 | -------------------------------------------------------------------------------- /inst/themes/navy.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #000035; 3 | } 4 | .num { 5 | color: #f87ff4; 6 | } 7 | .sng { 8 | color: #ff7f66; 9 | } 10 | .com { 11 | color: #ffbb00; 12 | font-style: italic; 13 | } 14 | .opt { 15 | color: #ffffff; 16 | } 17 | .def { 18 | color: #008bff; 19 | } 20 | .kwa { 21 | color: #f8c50b; 22 | font-weight: bold; 23 | } 24 | .kwb { 25 | color: #e1e72f; 26 | } 27 | .kwc { 28 | color: #13d8ef; 29 | } 30 | .kwd { 31 | color: #ffffff; 32 | } 33 | -------------------------------------------------------------------------------- /inst/themes/neon.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #303030; 3 | } 4 | .num { 5 | color: #92d4ff; 6 | } 7 | .sng { 8 | color: #92d4ff; 9 | } 10 | .com { 11 | color: #c0c0c0; 12 | } 13 | .opt { 14 | color: #f0f0f0; 15 | } 16 | .def { 17 | color: #f0f0f0; 18 | } 19 | .kwa { 20 | color: #dcdc78; 21 | } 22 | .kwb { 23 | color: #60f0a8; 24 | } 25 | .kwc { 26 | color: #7979db; 27 | } 28 | .kwd { 29 | color: #db79aa; 30 | } 31 | -------------------------------------------------------------------------------- /inst/themes/night.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #303040; 3 | } 4 | .num { 5 | color: #b8b8c8; 6 | } 7 | .sng { 8 | color: #f0f0f8; 9 | } 10 | .com { 11 | color: #e0e070; 12 | } 13 | .opt { 14 | color: #f0f0f8; 15 | } 16 | .def { 17 | color: #f0f0f8; 18 | } 19 | .kwa { 20 | color: #00d8f8; 21 | } 22 | .kwb { 23 | color: #bbaaff; 24 | } 25 | .kwc { 26 | color: #9d00f7; 27 | } 28 | .kwd { 29 | color: #cc66cc; 30 | } 31 | -------------------------------------------------------------------------------- /inst/themes/nightshimmer.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #103040; 3 | } 4 | .num { 5 | color: #00ffff; 6 | } 7 | .sng { 8 | color: #00ffff; 9 | } 10 | .com { 11 | color: #507080; 12 | } 13 | .opt { 14 | color: #e0eee0; 15 | } 16 | .def { 17 | color: #e0eee0; 18 | } 19 | .kwa { 20 | color: #90ee90; 21 | } 22 | .kwb { 23 | color: #add8e6; 24 | } 25 | .kwc { 26 | color: #cc99ff; 27 | } 28 | .kwd { 29 | color: #ff9999; 30 | } 31 | -------------------------------------------------------------------------------- /inst/themes/nuvola.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #F9F5F9; 3 | } 4 | .num { 5 | color: #00C226; 6 | } 7 | .sng { 8 | color: #B91F49; 9 | } 10 | .com { 11 | color: #3F6B5B; 12 | } 13 | .opt { 14 | color: #000000; 15 | } 16 | .def { 17 | color: #000000; 18 | } 19 | .kwa { 20 | color: #F06F00; 21 | } 22 | .kwb { 23 | color: #0000ff; 24 | } 25 | .kwc { 26 | color: #08f000; 27 | font-weight: bold; 28 | } 29 | .kwd { 30 | color: #e800f0; 31 | } 32 | -------------------------------------------------------------------------------- /inst/themes/olive.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #333300; 3 | } 4 | .num { 5 | color: #ffddad; 6 | } 7 | .sng { 8 | color: #afff2f; 9 | } 10 | .com { 11 | color: #bdb66b; 12 | } 13 | .opt { 14 | color: #D9D9C3; 15 | } 16 | .def { 17 | color: #D9D9C3; 18 | } 19 | .kwa { 20 | color: #8fbc8f; 21 | font-weight: bold; 22 | } 23 | .kwb { 24 | color: #daa520; 25 | } 26 | .kwc { 27 | color: #21d948; 28 | } 29 | .kwd { 30 | color: #D9D9C3; 31 | } 32 | -------------------------------------------------------------------------------- /inst/themes/orion.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #1E1616; 3 | } 4 | .num { 5 | color: #9C928C; 6 | } 7 | .sng { 8 | color: #635D63; 9 | } 10 | .com { 11 | color: #C4674A; 12 | } 13 | .opt { 14 | color: #7B94AD; 15 | } 16 | .def { 17 | color: #C4B1A8; 18 | } 19 | .kwa { 20 | color: #49d4d6; 21 | } 22 | .kwb { 23 | color: #BA1919; 24 | } 25 | .kwc { 26 | color: #7B2421; 27 | } 28 | .kwd { 29 | color: #AD5139; 30 | } 31 | -------------------------------------------------------------------------------- /inst/themes/oxygenated.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #0f0f0f; 3 | } 4 | .num { 5 | color: #0099CC; 6 | } 7 | .sng { 8 | color: #FFCC00; 9 | font-weight: bold; 10 | } 11 | .com { 12 | color: #00CC33; 13 | } 14 | .opt { 15 | color: #ff0099; 16 | font-weight: bold; 17 | } 18 | .def { 19 | color: #FFFF66; 20 | font-weight: bold; 21 | } 22 | .kwa { 23 | color: #99aaff; 24 | font-weight: bold; 25 | } 26 | .kwb { 27 | color: #66ff99; 28 | } 29 | .kwc { 30 | color: #ff99ff; 31 | } 32 | .kwd { 33 | color: #33ddee; 34 | } 35 | -------------------------------------------------------------------------------- /inst/themes/pablo.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #000000; 3 | } 4 | .num { 5 | color: #00ffff; 6 | } 7 | .sng { 8 | color: #00ffff; 9 | } 10 | .com { 11 | color: #808080; 12 | } 13 | .opt { 14 | color: #ff0000; 15 | } 16 | .def { 17 | color: #ffffff; 18 | } 19 | .kwa { 20 | color: #c0c000; 21 | font-weight: bold; 22 | } 23 | .kwb { 24 | color: #00c000; 25 | font-weight: bold; 26 | } 27 | .kwc { 28 | color: #3939bf; 29 | font-weight: bold; 30 | } 31 | .kwd { 32 | color: #21ffc0; 33 | } 34 | -------------------------------------------------------------------------------- /inst/themes/peaksea.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #e0e0e0; 3 | } 4 | .num { 5 | color: #907000; 6 | } 7 | .sng { 8 | color: #007068; 9 | } 10 | .com { 11 | color: #606000; 12 | } 13 | .opt { 14 | color: #000000; 15 | } 16 | .def { 17 | color: #000000; 18 | } 19 | .kwa { 20 | color: #2060a8; 21 | } 22 | .kwb { 23 | color: #0850a0; 24 | } 25 | .kwc { 26 | color: #a86920; 27 | } 28 | .kwd { 29 | color: #20a825; 30 | } 31 | -------------------------------------------------------------------------------- /inst/themes/print.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #ffffff; 3 | } 4 | .num { 5 | color: #000000; 6 | } 7 | .sng { 8 | color: #000000; 9 | } 10 | .com { 11 | color: #666666; 12 | font-style: italic; 13 | } 14 | .opt { 15 | color: #000000; 16 | font-weight: bold; 17 | } 18 | .def { 19 | color: #000000; 20 | } 21 | .kwa { 22 | color: #000000; 23 | font-weight: bold; 24 | } 25 | .kwb { 26 | color: #000000; 27 | font-weight: bold; 28 | } 29 | .kwc { 30 | color: #000000; 31 | font-weight: bold; 32 | } 33 | .kwd { 34 | color: #000000; 35 | font-weight: bold; 36 | } 37 | -------------------------------------------------------------------------------- /inst/themes/rand01.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #ffffff; 3 | } 4 | .num { 5 | color: #0da344; 6 | } 7 | .sng { 8 | color: #2b83ba; 9 | } 10 | .com { 11 | color: #ababab; 12 | font-style: italic; 13 | } 14 | .opt { 15 | color: #0000de; 16 | } 17 | .def { 18 | color: #121b28; 19 | } 20 | .kwa { 21 | color: #0a7f6d; 22 | font-weight: bold; 23 | } 24 | .kwb { 25 | color: #c42638; 26 | font-weight: bold; 27 | } 28 | .kwc { 29 | color: #e12f76; 30 | } 31 | .kwd { 32 | color: #2ac749; 33 | } 34 | -------------------------------------------------------------------------------- /inst/themes/rdark.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #1e2426; 3 | } 4 | .num { 5 | color: #8ae234; 6 | } 7 | .sng { 8 | color: #8ae234; 9 | } 10 | .com { 11 | color: #656763; 12 | } 13 | .opt { 14 | color: #babdb6; 15 | } 16 | .def { 17 | color: #babdb6; 18 | } 19 | .kwa { 20 | color: #729fcf; 21 | } 22 | .kwb { 23 | color: #e3e7df; 24 | } 25 | .kwc { 26 | color: #cfa272; 27 | } 28 | .kwd { 29 | color: #9ebd77; 30 | } 31 | -------------------------------------------------------------------------------- /inst/themes/relaxedgreen.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #000000; 3 | } 4 | .num { 5 | color: #0099dd; 6 | } 7 | .sng { 8 | color: #0099dd; 9 | } 10 | .com { 11 | color: #00a594; 12 | } 13 | .opt { 14 | color: #aaaaaa; 15 | } 16 | .def { 17 | color: #aaaaaa; 18 | } 19 | .kwa { 20 | color: #ac0000; 21 | } 22 | .kwb { 23 | color: #559955; 24 | } 25 | .kwc { 26 | color: #00abab; 27 | } 28 | .kwd { 29 | color: #ededed; 30 | } 31 | -------------------------------------------------------------------------------- /inst/themes/rootwater.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #151b1d; 3 | } 4 | .num { 5 | color: #77dd88; 6 | } 7 | .sng { 8 | color: #77dd88; 9 | } 10 | .com { 11 | color: #656565; 12 | } 13 | .opt { 14 | color: #babdb6; 15 | } 16 | .def { 17 | color: #babdb6; 18 | } 19 | .kwa { 20 | color: #8fffff; 21 | } 22 | .kwb { 23 | color: #ffffff; 24 | } 25 | .kwc { 26 | color: #ff8f8f; 27 | } 28 | .kwd { 29 | color: #ededed; 30 | } 31 | -------------------------------------------------------------------------------- /inst/themes/seashell.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #fff5ee; 3 | } 4 | .num { 5 | color: #ff1493; 6 | } 7 | .sng { 8 | color: #ff1493; 9 | } 10 | .com { 11 | color: #2929cc; 12 | } 13 | .opt { 14 | color: #676767; 15 | } 16 | .def { 17 | color: #000000; 18 | } 19 | .kwa { 20 | color: #2e8b57; 21 | font-weight: bold; 22 | } 23 | .kwb { 24 | color: #2e8b57; 25 | font-weight: bold; 26 | } 27 | .kwc { 28 | color: #696969; 29 | font-weight: bold; 30 | } 31 | .kwd { 32 | color: #00008f; 33 | } 34 | -------------------------------------------------------------------------------- /inst/themes/solarized-dark.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #002b36; 3 | } 4 | .num { 5 | color: #dc322f; 6 | } 7 | .sng { 8 | color: #dc322f; 9 | } 10 | .com { 11 | color: #586e75; 12 | } 13 | .opt { 14 | color: #93a1a1; 15 | } 16 | .def { 17 | color: #839496; 18 | } 19 | .kwa { 20 | color: #cb4b16; 21 | } 22 | .kwb { 23 | color: #859900; 24 | } 25 | .kwc { 26 | color: #cb4b16; 27 | } 28 | .kwd { 29 | color: #93a1a1; 30 | } 31 | -------------------------------------------------------------------------------- /inst/themes/solarized-light.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #fdf6e3; 3 | } 4 | .num { 5 | color: #dc322f; 6 | } 7 | .sng { 8 | color: #dc322f; 9 | } 10 | .com { 11 | color: #93a1a1; 12 | } 13 | .opt { 14 | color: #586e75; 15 | } 16 | .def { 17 | color: #657b83; 18 | } 19 | .kwa { 20 | color: #cb4b16; 21 | } 22 | .kwb { 23 | color: #859900; 24 | } 25 | .kwc { 26 | color: #cb4b16; 27 | } 28 | .kwd { 29 | color: #586e75; 30 | } 31 | -------------------------------------------------------------------------------- /inst/themes/tabula.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #004A41; 3 | } 4 | .num { 5 | color: #00A7F7; 6 | } 7 | .sng { 8 | color: #00DF00; 9 | } 10 | .com { 11 | color: #00C5E7; 12 | } 13 | .opt { 14 | color: #71D289; 15 | } 16 | .def { 17 | color: #71D289; 18 | } 19 | .kwa { 20 | color: #DEDE00; 21 | font-weight: bold; 22 | } 23 | .kwb { 24 | color: #F269E4; 25 | } 26 | .kwc { 27 | color: #ffffff; 28 | } 29 | .kwd { 30 | color: #ff7f00; 31 | } 32 | -------------------------------------------------------------------------------- /inst/themes/tcsoft.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #FFFFFF; 3 | } 4 | .num { 5 | color: #666666; 6 | } 7 | .sng { 8 | color: #666666; 9 | } 10 | .com { 11 | color: #000099; 12 | font-style: italic; 13 | } 14 | .opt { 15 | color: #000000; 16 | } 17 | .def { 18 | color: #000000; 19 | } 20 | .kwa { 21 | color: #FF9900; 22 | } 23 | .kwb { 24 | color: #FF9900; 25 | font-weight: bold; 26 | } 27 | .kwc { 28 | color: #0066ff; 29 | } 30 | .kwd { 31 | color: #ff00e5; 32 | } 33 | -------------------------------------------------------------------------------- /inst/themes/vampire.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #000000; 3 | } 4 | .num { 5 | color: #aaff00; 6 | } 7 | .sng { 8 | color: #bb00ff; 9 | } 10 | .com { 11 | color: #ababab; 12 | font-style: italic; 13 | } 14 | .opt { 15 | color: #F3E651; 16 | } 17 | .def { 18 | color: #ff0000; 19 | } 20 | .kwa { 21 | color: #ffffff; 22 | font-weight: bold; 23 | } 24 | .kwb { 25 | color: #F35E1E; 26 | font-weight: bold; 27 | } 28 | .kwc { 29 | color: #ffffff; 30 | } 31 | .kwd { 32 | color: #ffcc33; 33 | } 34 | -------------------------------------------------------------------------------- /inst/themes/whitengrey.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #ffffff; 3 | } 4 | .num { 5 | color: #bb00ff; 6 | } 7 | .sng { 8 | color: #008800; 9 | } 10 | .com { 11 | color: #1326a2; 12 | font-style: italic; 13 | } 14 | .opt { 15 | color: #696969; 16 | } 17 | .def { 18 | color: #696969; 19 | } 20 | .kwa { 21 | color: #696969; 22 | font-weight: bold; 23 | } 24 | .kwb { 25 | color: #696969; 26 | } 27 | .kwc { 28 | color: #696969; 29 | font-weight: bold; 30 | } 31 | .kwd { 32 | color: #000000; 33 | } 34 | -------------------------------------------------------------------------------- /inst/themes/xoria256.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #1c1c1c; 3 | } 4 | .num { 5 | color: #dfaf87; 6 | } 7 | .sng { 8 | color: #ffffaf; 9 | } 10 | .com { 11 | color: #808080; 12 | } 13 | .opt { 14 | color: #d0d0d0; 15 | } 16 | .def { 17 | color: #d0d0d0; 18 | } 19 | .kwa { 20 | color: #87afdf; 21 | } 22 | .kwb { 23 | color: #87de8c; 24 | } 25 | .kwc { 26 | color: #deb787; 27 | } 28 | .kwd { 29 | color: #de87da; 30 | } 31 | -------------------------------------------------------------------------------- /inst/themes/zellner.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #ffffff; 3 | } 4 | .num { 5 | color: #ff0066; 6 | } 7 | .sng { 8 | color: #ff00ff; 9 | } 10 | .com { 11 | color: #ff0000; 12 | } 13 | .opt { 14 | color: #000000; 15 | } 16 | .def { 17 | color: #000000; 18 | } 19 | .kwa { 20 | color: #a52a2a; 21 | } 22 | .kwb { 23 | color: #0000ff; 24 | } 25 | .kwc { 26 | color: #225f2d; 27 | } 28 | .kwd { 29 | color: #000000; 30 | font-weight: bold; 31 | } 32 | -------------------------------------------------------------------------------- /inst/themes/zenburn.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #1f1f1f; 3 | } 4 | .num { 5 | color: #dca3a3; 6 | font-weight: bold; 7 | } 8 | .sng { 9 | color: #cc9393; 10 | } 11 | .com { 12 | color: #7f9f7f; 13 | font-style: italic; 14 | } 15 | .opt { 16 | color: #dcdccc; 17 | } 18 | .def { 19 | color: #dcdccc; 20 | } 21 | .kwa { 22 | color: #e3ceab; 23 | } 24 | .kwb { 25 | color: #dfdfbf; 26 | font-weight: bold; 27 | } 28 | .kwc { 29 | color: #aae3b2; 30 | } 31 | .kwd { 32 | color: #aabfe3; 33 | } 34 | -------------------------------------------------------------------------------- /inst/themes/zmrok.css: -------------------------------------------------------------------------------- 1 | .background { 2 | color: #141414; 3 | } 4 | .num { 5 | color: #FACE43; 6 | } 7 | .sng { 8 | color: #D9FF77; 9 | } 10 | .com { 11 | color: #888888; 12 | } 13 | .opt { 14 | color: #F8F8F8; 15 | } 16 | .def { 17 | color: #F8F8F8; 18 | } 19 | .kwa { 20 | color: #A56A30; 21 | font-weight: bold; 22 | } 23 | .kwb { 24 | color: #C7CA87; 25 | } 26 | .kwc { 27 | color: #30a630; 28 | } 29 | .kwd { 30 | color: #3b84cc; 31 | } 32 | -------------------------------------------------------------------------------- /knitr.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | ProjectId: aebca7ed-54a0-42eb-85a8-80428da985f9 3 | 4 | RestoreWorkspace: Default 5 | SaveWorkspace: Default 6 | AlwaysSaveHistory: Default 7 | 8 | EnableCodeIndexing: Yes 9 | UseSpacesForTab: Yes 10 | NumSpacesForTab: 2 11 | Encoding: UTF-8 12 | 13 | RnwWeave: knitr 14 | LaTeX: pdfLaTeX 15 | 16 | AutoAppendNewline: Yes 17 | StripTrailingWhitespace: Yes 18 | 19 | BuildType: Package 20 | PackageInstallArgs: -v && Rscript -e "Rd2roxygen::rab(build=F,install=T)" 21 | PackageBuildArgs: -v && Rscript -e "Rd2roxygen::rab(build=T,install=T)" 22 | PackageCheckArgs: --as-cran 23 | -------------------------------------------------------------------------------- /man/all_labels.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/parser.R 3 | \name{all_labels} 4 | \alias{all_labels} 5 | \alias{all_rcpp_labels} 6 | \title{Get all chunk labels in a document} 7 | \usage{ 8 | all_labels(...) 9 | 10 | all_rcpp_labels(...) 11 | } 12 | \arguments{ 13 | \item{...}{A vector of R expressions, each of which should return \code{TRUE} 14 | or \code{FALSE}. The expressions are evaluated using the \emph{local} chunk 15 | options of each code chunk as the environment, which means global chunk 16 | options are not considered when evaluating these expressions. For example, 17 | if you set the global chunk option \code{opts_chunk$set(purl = TRUE)}, 18 | \code{all_labels(purl == TRUE)} will \emph{not} return the labels of all 19 | code chunks, but will only return the labels of those code chunks that have 20 | local chunk options \code{purl = TRUE}.} 21 | } 22 | \value{ 23 | A character vector. 24 | } 25 | \description{ 26 | The function \code{all_labels()} returns all chunk labels as a character 27 | vector. Optionally, you can specify a series of conditions to filter the 28 | labels. The function `all_rcpp_labels()` is a wrapper function for 29 | \code{all_labels(engine == 'Rcpp')}. 30 | } 31 | \details{ 32 | For example, suppose the condition expression is \code{engine == 'Rcpp'}, the 33 | object \code{engine} is the local chunk option \code{engine}. If an 34 | expression fails to be evaluated (e.g. when a certain object does not exist), 35 | \code{FALSE} is returned and the label for this chunk will be filtered out. 36 | } 37 | \note{ 38 | Empty code chunks are always ignored, including those chunks that are 39 | empty in the original document but filled with code using chunk options 40 | such as \code{ref.label} or \code{code}. 41 | } 42 | \examples{ 43 | # the examples below are meaningless unless you put them in a knitr document 44 | all_labels() 45 | all_labels(engine == "Rcpp") 46 | all_labels(echo == FALSE && results != "hide") 47 | # or separate the two conditions 48 | all_labels(echo == FALSE, results != "hide") 49 | } 50 | -------------------------------------------------------------------------------- /man/all_patterns.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/pattern.R 3 | \docType{data} 4 | \name{all_patterns} 5 | \alias{all_patterns} 6 | \title{All built-in patterns} 7 | \format{ 8 | An object of class \code{list} of length 8. 9 | } 10 | \usage{ 11 | all_patterns 12 | } 13 | \description{ 14 | This object is a named list of all built-in patterns. 15 | } 16 | \examples{ 17 | all_patterns$rnw 18 | all_patterns$html 19 | 20 | str(all_patterns) 21 | } 22 | \references{ 23 | Usage: \url{https://yihui.org/knitr/patterns/} 24 | } 25 | \seealso{ 26 | \code{\link{knit_patterns}} 27 | } 28 | \keyword{datasets} 29 | -------------------------------------------------------------------------------- /man/asis_output.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/output.R 3 | \name{asis_output} 4 | \alias{asis_output} 5 | \title{Mark an R object with a special class} 6 | \usage{ 7 | asis_output(x, meta = NULL, cacheable = NA) 8 | } 9 | \arguments{ 10 | \item{x}{An R object. Typically a character string, or an object which can 11 | be converted to a character string via \code{\link{as.character}()}.} 12 | 13 | \item{meta}{Additional metadata of the object to be printed. The metadata 14 | will be collected when the object is printed, and accessible via 15 | \code{knit_meta()}.} 16 | 17 | \item{cacheable}{Boolean indicating whether this object is cacheable. If 18 | \code{FALSE}, \pkg{knitr} will stop when caching is enabled on code chunks 19 | that contain \code{asis_output()}.} 20 | } 21 | \description{ 22 | This is a convenience function that assigns the input object a class named 23 | \code{knit_asis}, so that \pkg{knitr} will treat it as is (the effect is the 24 | same as the chunk option \code{results = 'asis'}) when it is written to the 25 | output. 26 | } 27 | \details{ 28 | This function is normally used in a custom S3 method based on the printing 29 | function \code{\link{knit_print}()}. 30 | 31 | For the \code{cacheable} argument, you need to be careful when printing the 32 | object involves non-trivial side effects, in which case it is strongly 33 | recommended to use \code{cacheable = FALSE} to instruct \pkg{knitr} that this 34 | object should not be cached using the chunk option \code{cache = TRUE}, 35 | otherwise the side effects will be lost the next time the chunk is knitted. 36 | For example, printing a \pkg{shiny} input element or an HTML widget in an R 37 | Markdown document may involve registering metadata about some JavaScript 38 | libraries or stylesheets, and the metadata may be lost if we cache the code 39 | chunk, because the code evaluation will be skipped the next time. This 40 | particular issue has been solved in \pkg{knitr} after v1.13 (the metadata 41 | will be saved and loaded automatically when caching is enabled), but not all 42 | metadata can be saved and loaded next time and still works in the new R 43 | session. 44 | } 45 | \note{ 46 | This function only works in top-level R expressions, and it will not 47 | work when it is called inside another expression, such as a for-loop. See 48 | \url{https://github.com/yihui/knitr/issues/1137} for a discussion. 49 | } 50 | \examples{ 51 | # see ?knit_print 52 | } 53 | -------------------------------------------------------------------------------- /man/cache_engines.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/engine.R 3 | \docType{data} 4 | \name{cache_engines} 5 | \alias{cache_engines} 6 | \title{Cache engines of other languages} 7 | \format{ 8 | An object of class \code{list} of length 7. 9 | } 10 | \usage{ 11 | cache_engines 12 | } 13 | \description{ 14 | This object controls how to load cached environments from languages other 15 | than R (when the chunk option \code{engine} is not \code{'R'}). Each 16 | component in this object is a function that takes the current path to the 17 | chunk cache and loads it into the language environment. 18 | } 19 | \details{ 20 | The cache engine function has one argument \code{options}, a list containing 21 | all chunk options. Note that \code{options$hash} is the path to the current 22 | chunk cache with the chunk's hash, but without any file extension, and the 23 | language engine may write a cache database to this path (with an extension). 24 | 25 | The cache engine function should load the cache environment and should know 26 | the extension appropriate for the language. 27 | } 28 | \references{ 29 | See \url{https://github.com/rstudio/reticulate/pull/167} for an 30 | implementation of a cache engine for Python. 31 | } 32 | \keyword{datasets} 33 | -------------------------------------------------------------------------------- /man/clean_cache.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/cache.R 3 | \name{clean_cache} 4 | \alias{clean_cache} 5 | \title{Clean cache files that are probably no longer needed} 6 | \usage{ 7 | clean_cache(clean = FALSE, path = opts_chunk$get("cache.path")) 8 | } 9 | \arguments{ 10 | \item{clean}{Boolean; whether to remove the files.} 11 | 12 | \item{path}{Path to the cache.} 13 | } 14 | \description{ 15 | If you remove or rename some cached code chunks, their original cache files 16 | will not be automatically cleaned. You can use this function to identify 17 | these possible files, and clean them if you are sure they are no longer 18 | needed. 19 | } 20 | \note{ 21 | The identification is not guaranteed to be correct, especially when 22 | multiple documents share the same cache directory. You are recommended to 23 | call \code{clean_cache(FALSE)} and carefully check the list of files (if 24 | any) before you really delete them (\code{clean_cache(TRUE)}). 25 | 26 | This function must be called within a code chunk in a source document, 27 | since it needs to know all chunk labels of the current document to 28 | determine which labels are no longer present, and delete cache 29 | corresponding to these labels. 30 | } 31 | -------------------------------------------------------------------------------- /man/combine_words.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{combine_words} 4 | \alias{combine_words} 5 | \title{Combine multiple words into a single string} 6 | \usage{ 7 | combine_words(...) 8 | } 9 | \arguments{ 10 | \item{...}{Arguments passed to \code{xfun::\link[xfun]{join_words}()}.} 11 | } 12 | \description{ 13 | This is a wrapper function of \code{xfun::join_words()}. 14 | } 15 | -------------------------------------------------------------------------------- /man/current_input.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{current_input} 4 | \alias{current_input} 5 | \title{Query the current input filename} 6 | \usage{ 7 | current_input(dir = FALSE) 8 | } 9 | \arguments{ 10 | \item{dir}{Boolean; whether to prepend the current working directory to the file path, 11 | i.e. whether to return an absolute path or a relative path.} 12 | } 13 | \value{ 14 | A character string, if this function is called inside an input 15 | document. Otherwise \code{NULL}. 16 | } 17 | \description{ 18 | Returns the name of the input file passed to \code{\link{knit}()}. 19 | } 20 | -------------------------------------------------------------------------------- /man/dep_auto.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/cache.R 3 | \name{dep_auto} 4 | \alias{dep_auto} 5 | \title{Build automatic dependencies among chunks} 6 | \usage{ 7 | dep_auto(path = opts_chunk$get("cache.path"), labels = all_labels()) 8 | } 9 | \arguments{ 10 | \item{path}{Path to the dependency file.} 11 | 12 | \item{labels}{A vector of labels of chunks for which the dependencies will be 13 | built. By default, dependencies for all chunks will be built.} 14 | } 15 | \value{ 16 | \code{NULL}. The dependencies are built as a side effect. 17 | } 18 | \description{ 19 | When the chunk option \code{autodep = TRUE}, all names of objects created in 20 | a chunk will be saved in a file named \file{__objects} and all global objects 21 | used in a chunk will be saved to \file{__globals}. This function can analyze 22 | object names in these files to automatically build cache dependencies, which 23 | is similar to the effect of the \code{dependson} option. It is supposed to be 24 | used in the first chunk of a document and this chunk must not be cached. 25 | } 26 | \note{ 27 | Be cautious about \code{path}: because this function is used in a 28 | chunk, the working directory when the chunk is evaluated is the directory 29 | of the input document in \code{\link{knit}}, and if that directory differs 30 | from the working directory before calling \code{knit()}, you need to adjust 31 | the \code{path} argument here to make sure this function can find the cache 32 | files \file{__objects} and \file{__globals}. 33 | } 34 | \references{ 35 | \url{https://yihui.org/knitr/demo/cache/} 36 | } 37 | \seealso{ 38 | \code{\link{dep_prev}} 39 | } 40 | -------------------------------------------------------------------------------- /man/dep_prev.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/cache.R 3 | \name{dep_prev} 4 | \alias{dep_prev} 5 | \title{Make later chunks depend on previous chunks} 6 | \usage{ 7 | dep_prev() 8 | } 9 | \value{ 10 | \code{NULL}; the internal dependency structure is updated as a side 11 | effect. 12 | } 13 | \description{ 14 | This function can be used to build dependencies among chunks so that all 15 | later chunks depend on previous chunks, i.e. whenever the cache of a previous 16 | chunk is updated, the cache of all its later chunks will be updated. 17 | } 18 | \references{ 19 | \url{https://yihui.org/knitr/demo/cache/} 20 | } 21 | \seealso{ 22 | \code{\link{dep_auto}} 23 | } 24 | -------------------------------------------------------------------------------- /man/download_image.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plot.R 3 | \name{download_image} 4 | \alias{download_image} 5 | \title{Download an image from the web and include it in a document} 6 | \usage{ 7 | download_image( 8 | url, 9 | path = xfun::url_filename(url), 10 | use_file = !pandoc_to("html"), 11 | ... 12 | ) 13 | } 14 | \arguments{ 15 | \item{url}{The URL of an image.} 16 | 17 | \item{path}{The download path (inferred from the URL by default). If the file 18 | exists, it will not be downloaded (downloading can take time and requires 19 | Internet connection). If you are sure the file needs to be downloaded 20 | again, delete it beforehand.} 21 | 22 | \item{use_file}{Whether to use the URL or the download path to include the 23 | image. By default, the URL is used for HTML output formats, and the file 24 | path is used for other output formats.} 25 | 26 | \item{...}{Other arguments to be passed to \code{\link{include_graphics}()}.} 27 | } 28 | \description{ 29 | When including images in non-HTML output formats such as LaTeX/PDF, URLs will 30 | not work as image paths. In this case, we have to download the images. This 31 | function is a wrapper of \code{xfun::\link[xfun]{download_file}()} and 32 | \code{\link{include_graphics}()}. 33 | } 34 | \examples{\dontshow{if (interactive()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} 35 | knitr::download_image("https://www.r-project.org/Rlogo.png") 36 | \dontshow{\}) # examplesIf} 37 | } 38 | -------------------------------------------------------------------------------- /man/engine_output.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/engine.R 3 | \name{engine_output} 4 | \alias{engine_output} 5 | \title{An output wrapper for language engine output} 6 | \usage{ 7 | engine_output(options, code, out, extra = NULL) 8 | } 9 | \arguments{ 10 | \item{options}{A list of chunk options. Usually this is just the object 11 | \code{options} passed to the engine function; see 12 | \code{\link{knit_engines}}.} 13 | 14 | \item{code}{Source code of the chunk, to which the output hook \code{source} 15 | is applied, unless the chunk option \code{echo} is \code{FALSE}.} 16 | 17 | \item{out}{Text output from the engine, to which the hook \code{output} is 18 | applied, unless the chunk option \code{results} is \code{'hide'}} 19 | 20 | \item{extra}{Any additional text output that you want to include.} 21 | } 22 | \value{ 23 | A character string generated from the source code and output using 24 | the appropriate output hooks. 25 | } 26 | \description{ 27 | If you have designed a language engine, you may call this function in the end 28 | to format and return the text output from your engine. 29 | } 30 | \details{ 31 | For expert users, an advanced usage of this function is 32 | \code{engine_output(options, out = LIST)} where \code{LIST} is a list that 33 | has the same structure as the output of \code{evaluate::evaluate()}. In this 34 | case, the arguments \code{code} and \code{extra} are ignored, and the list is 35 | passed to \code{knitr::sew()} to return a character vector of final output. 36 | } 37 | \examples{ 38 | library(knitr) 39 | engine_output(opts_chunk$merge(list(engine = "Rscript")), 40 | code = "1 + 1", out = "[1] 2") 41 | engine_output(opts_chunk$merge(list(echo = FALSE, engine = "Rscript")), 42 | code = "1 + 1", out = "[1] 2") 43 | 44 | # expert use only 45 | engine_output(opts_chunk$merge(list(engine = "python")), 46 | out = list(structure(list(src = "1 + 1"), class = "source"), 47 | "2")) 48 | } 49 | -------------------------------------------------------------------------------- /man/fig_chunk.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{fig_chunk} 4 | \alias{fig_chunk} 5 | \title{Obtain the figure filenames for a chunk} 6 | \usage{ 7 | fig_chunk(label, ext = "", number, fig.path = opts_chunk$get("fig.path")) 8 | } 9 | \arguments{ 10 | \item{label}{The chunk label.} 11 | 12 | \item{ext}{The figure file extension, e.g. \code{png} or \code{pdf}.} 13 | 14 | \item{number}{The figure number (by default \code{1}).} 15 | 16 | \item{fig.path}{Passed to \code{\link{fig_path}}. By default, the chunk 17 | option \code{fig.path} is used.} 18 | } 19 | \value{ 20 | A character vector of filenames. 21 | } 22 | \description{ 23 | Given a chunk label, the figure file extension, the figure number(s), and the 24 | chunk option \code{fig.path}, return the filename(s). 25 | } 26 | \details{ 27 | This function can be used in an inline R expression to write out the figure 28 | filenames without hard-coding them. For example, if you created a plot in a 29 | code chunk with the label \code{foo} and figure path \file{my-figure/}, you 30 | are not recommended to use hard-coded figure paths like 31 | \samp{\includegraphics{my-figure/foo-1.pdf}} (in \file{.Rnw} documents) or 32 | \samp{![](my-figure/foo-1.png)} (R Markdown) in your document. Instead, you 33 | should use \samp{\\Sexpr{fig_chunk('foo', 'pdf')}} or \samp{![](`r 34 | fig_chunk('foo', 'png')`)}. 35 | 36 | You can generate plots in a code chunk but not show them inside the code 37 | chunk by using the chunk option \code{fig.show = 'hide'}. Then you can use 38 | this function if you want to show them elsewhere. 39 | } 40 | \examples{ 41 | library(knitr) 42 | fig_chunk("foo", "png") 43 | fig_chunk("foo", "pdf") 44 | fig_chunk("foo", "svg", 2) # the second plot of the chunk foo 45 | fig_chunk("foo", "png", 1:5) # if the chunk foo produced 5 plots 46 | } 47 | -------------------------------------------------------------------------------- /man/fig_path.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{fig_path} 4 | \alias{fig_path} 5 | \title{Path for figure files} 6 | \usage{ 7 | fig_path(suffix = "", options = opts_current$get(), number) 8 | } 9 | \arguments{ 10 | \item{suffix}{A filename suffix; if it is non-empty and does not 11 | contain a dot \code{.}, it will be treated as the filename extension (e.g. 12 | \code{png} will be used as \code{.png})} 13 | 14 | \item{options}{A list of options; by default the options of the current chunk.} 15 | 16 | \item{number}{The current figure number. The default is the internal chunk option 17 | \code{fig.cur}, if this is available.} 18 | } 19 | \value{ 20 | A character vector of the form \file{fig.path-label-i.suffix}. 21 | } 22 | \description{ 23 | The filename of figure files is the combination of options \code{fig.path} 24 | and \code{label}. This function returns the path of figures for the current 25 | chunk by default. 26 | } 27 | \note{ 28 | When there are special characters (not alphanumeric or \samp{-} or 29 | \samp{_}) in the path, they will be automatically replaced with \samp{_}. 30 | For example, \file{a b/c.d-} will be sanitized to \file{a_b/c_d-}. This 31 | makes the filenames safe to LaTeX. 32 | } 33 | \examples{ 34 | fig_path(".pdf", options = list(fig.path = "figure/abc-", label = "first-plot")) 35 | fig_path(".png", list(fig.path = "foo-", label = "bar"), 1:10) 36 | } 37 | -------------------------------------------------------------------------------- /man/hook_animation.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/hooks-html.R 3 | \name{hook_ffmpeg_html} 4 | \alias{hook_ffmpeg_html} 5 | \alias{hook_gifski} 6 | \alias{hook_scianimator} 7 | \alias{hook_r2swf} 8 | \title{Hooks to create animations in HTML output} 9 | \usage{ 10 | hook_ffmpeg_html(x, options) 11 | 12 | hook_gifski(x, options) 13 | 14 | hook_scianimator(x, options) 15 | 16 | hook_r2swf(x, options) 17 | } 18 | \arguments{ 19 | \item{x}{Filename for the plot (a character string).} 20 | 21 | \item{options}{A list of the current chunk options.} 22 | } 23 | \description{ 24 | \code{hook_ffmpeg_html()} uses FFmpeg to convert images to a video; 25 | \code{hook_gifski()} uses the \pkg{gifski} to convert images to a GIF 26 | animation; \code{hook_scianimator()} uses the JavaScript library SciAnimator 27 | to create animations; \code{hook_r2swf()} uses the \pkg{R2SWF} package. 28 | } 29 | \details{ 30 | These hooks are mainly for the package option \code{animation.fun}, e.g. you 31 | can set \code{opts_knit$set(animation.fun = hook_scianimator)}. 32 | } 33 | -------------------------------------------------------------------------------- /man/hook_document.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/hooks-latex.R 3 | \name{hook_movecode} 4 | \alias{hook_movecode} 5 | \title{Some potentially useful document hooks} 6 | \usage{ 7 | hook_movecode(x) 8 | } 9 | \arguments{ 10 | \item{x}{A character string (the whole output document).} 11 | } 12 | \value{ 13 | The post-processed document as a character string. 14 | } 15 | \description{ 16 | A document hook is a function to post-process the output document. 17 | } 18 | \details{ 19 | \code{hook_movecode()} is a document hook to move code chunks out of LaTeX 20 | floating environments like \samp{figure} and \samp{table} when the chunks 21 | were actually written inside the floats. This function is primarily designed 22 | for LyX: we often insert code chunks into floats to generate figures or 23 | tables, but in the final output we do not want the code to float with the 24 | environments, so we use regular expressions to find out the floating 25 | environments, extract the code chunks and move them out. To disable this 26 | behavior, use a comment \code{\% knitr_do_not_move} in the floating 27 | environment. 28 | } 29 | \note{ 30 | These functions are hackish. Also note \code{hook_movecode()} assumes 31 | you to use the default output hooks for LaTeX (not Sweave or listings), and 32 | every figure/table environment must have a label. 33 | } 34 | \examples{ 35 | \dontrun{ 36 | knit_hooks$set(document = hook_movecode) 37 | } 38 | # see example 103 at https://github.com/yihui/knitr-examples 39 | } 40 | \references{ 41 | \url{https://yihui.org/knitr/hooks/} 42 | } 43 | -------------------------------------------------------------------------------- /man/image_uri.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{image_uri} 4 | \alias{image_uri} 5 | \title{Encode an image file to a data URI} 6 | \usage{ 7 | image_uri(f) 8 | } 9 | \arguments{ 10 | \item{f}{Path to the image file.} 11 | } 12 | \value{ 13 | The data URI as a character string. 14 | } 15 | \description{ 16 | This function is the same as \code{xfun::\link[xfun]{base64_uri}()} (only with a 17 | different function name). It can encode an image file as a base64 string, 18 | which can be used in the \code{img} tag in HTML. 19 | } 20 | \examples{ 21 | uri = image_uri(file.path(R.home("doc"), "html", "logo.jpg")) 22 | if (interactive()) { 23 | cat(sprintf("", uri), file = "logo.html") 24 | browseURL("logo.html") # you can check its HTML source 25 | } 26 | } 27 | \references{ 28 | \url{https://en.wikipedia.org/wiki/Data_URI_scheme} 29 | } 30 | \author{ 31 | Wush Wu and Yihui Xie 32 | } 33 | -------------------------------------------------------------------------------- /man/imgur_upload.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils-upload.R 3 | \name{imgur_upload} 4 | \alias{imgur_upload} 5 | \title{Upload an image to imgur.com} 6 | \usage{ 7 | imgur_upload(file, key = xfun::env_option("knitr.imgur.key"), ...) 8 | } 9 | \arguments{ 10 | \item{file, key, ...}{See \code{xfun::\link[xfun]{upload_imgur}()}.} 11 | } 12 | \description{ 13 | This function is an alias to \code{xfun::upload_imgur()}. It is kept in 14 | \pkg{knitr} only for backward-compatibility reasons. You are recommended to 15 | use \code{xfun::upload_imgur()} directly instead. 16 | } 17 | \keyword{internal} 18 | -------------------------------------------------------------------------------- /man/include_url.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plot.R 3 | \name{include_url} 4 | \alias{include_url} 5 | \alias{include_app} 6 | \title{Embed a URL as an HTML iframe or a screenshot in \pkg{knitr} documents} 7 | \usage{ 8 | include_url(url, height = "400px") 9 | 10 | include_app(url, height = "400px") 11 | } 12 | \arguments{ 13 | \item{url}{A character vector of URLs.} 14 | 15 | \item{height}{A character vector to specify the height of iframes.} 16 | } 17 | \value{ 18 | An R object with a special class that \pkg{knitr} recognizes 19 | internally to generate the iframes or screenshots. 20 | } 21 | \description{ 22 | When the output format is HTML, \code{include_url()} inserts an iframe in the 23 | output; otherwise it takes a screenshot of the URL and insert the image in 24 | the output. \code{include_app()} takes the URL of a Shiny app and adds 25 | \samp{?showcase=0} to it (to disable the showcase mode), then passes the URL 26 | to \code{include_url()}. 27 | } 28 | \seealso{ 29 | \code{\link{include_graphics}} 30 | } 31 | -------------------------------------------------------------------------------- /man/inline_expr.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/parser.R 3 | \name{inline_expr} 4 | \alias{inline_expr} 5 | \title{Wrap code using the inline R expression syntax} 6 | \usage{ 7 | inline_expr(code, syntax) 8 | } 9 | \arguments{ 10 | \item{code}{Character string of the inline R source code.} 11 | 12 | \item{syntax}{A character string to specify the syntax, e.g. \code{rnw}, 13 | \code{html}, or \code{md}. If not specified, this will be guessed from 14 | the knitting context.} 15 | } 16 | \value{ 17 | A character string marked up using the inline R code syntax. 18 | } 19 | \description{ 20 | This is a convenience function to write the "source code" of inline R 21 | expressions. For example, if you want to write \samp{`r 1+1`} literally in an 22 | R Markdown document, you may write \samp{`` `r knitr::inline_expr('1+1')` 23 | ``}; for Rnw documents, this may be 24 | \samp{\verb|\Sexpr{knitr::inline_expr{'1+1'}}|}. 25 | } 26 | \examples{ 27 | library(knitr) 28 | inline_expr("1+1", "rnw") 29 | inline_expr("1+1", "html") 30 | inline_expr("1+1", "md") 31 | } 32 | -------------------------------------------------------------------------------- /man/is_low_change.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plot.R 3 | \name{is_low_change} 4 | \alias{is_low_change} 5 | \title{Compare two recorded plots} 6 | \usage{ 7 | is_low_change(p1, p2) 8 | } 9 | \arguments{ 10 | \item{p1, p2}{Plot objects.} 11 | } 12 | \value{ 13 | Logical value indicating whether \code{p2} is a low-level update of 14 | \code{p1}. 15 | } 16 | \description{ 17 | Check if one plot only contains a low-level update of another plot. 18 | } 19 | \examples{ 20 | pdf(NULL) 21 | dev.control("enable") # enable plot recording 22 | plot(1:10) 23 | p1 = recordPlot() 24 | abline(0, 1) # add a line (a low-level change) 25 | p2 = recordPlot() 26 | plot(rnorm(100)) 27 | p3 = recordPlot() # draw a completely new plot 28 | dev.off() 29 | knitr::is_low_change(p1, p2) # true 30 | knitr::is_low_change(p1, p3) # false 31 | } 32 | -------------------------------------------------------------------------------- /man/knit2html.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils-conversion.R 3 | \name{knit2html} 4 | \alias{knit2html} 5 | \title{Convert markdown to HTML using knit() and mark_html()} 6 | \usage{ 7 | knit2html( 8 | input, 9 | output = NULL, 10 | ..., 11 | envir = parent.frame(), 12 | text = NULL, 13 | quiet = FALSE, 14 | encoding = "UTF-8", 15 | force_v1 = getOption("knitr.knit2html.force_v1", FALSE) 16 | ) 17 | } 18 | \arguments{ 19 | \item{input}{Path to the input file.} 20 | 21 | \item{output}{Path to the output file for \code{knit()}. If \code{NULL}, this 22 | function will try to guess a default, which will be under the current 23 | working directory.} 24 | 25 | \item{...}{Options passed to 26 | \code{markdown::\link[markdown]{mark_html}()}.} 27 | 28 | \item{envir}{Environment in which code chunks are to be evaluated, for 29 | example, \code{\link{parent.frame}()}, \code{\link{new.env}()}, or 30 | \code{\link{globalenv}()}).} 31 | 32 | \item{text}{A character vector. This is an alternative way to provide the 33 | input file.} 34 | 35 | \item{quiet}{Boolean; suppress the progress bar and messages?} 36 | 37 | \item{encoding}{Encoding of the input file; always assumed to be UTF-8 (i.e., 38 | this argument is effectively ignored).} 39 | 40 | \item{force_v1}{Boolean; whether to force rendering the input document as an 41 | R Markdown v1 document, even if it is for v2.} 42 | } 43 | \value{ 44 | If the argument \code{text} is NULL, a character string (HTML code) 45 | is returned; otherwise the result is written into a file and the filename 46 | is returned. 47 | } 48 | \description{ 49 | This is a convenience function to knit the input markdown source and call 50 | \code{markdown::\link[markdown]{mark_html}()} in the \pkg{markdown} 51 | package to convert the result to HTML. 52 | } 53 | \note{ 54 | The \pkg{markdown} package is for R Markdown v1, which is much less 55 | powerful than R Markdown v2, i.e. the \pkg{rmarkdown} package 56 | (\url{https://rmarkdown.rstudio.com}). To render R Markdown v2 documents to 57 | HTML, please use \code{rmarkdown::render()} instead. 58 | } 59 | \examples{ 60 | # a minimal example 61 | writeLines(c("# hello markdown", "```{r hello-random, echo=TRUE}", "rnorm(5)", "```"), 62 | "test.Rmd") 63 | knit2html("test.Rmd") 64 | if (interactive()) browseURL("test.html") 65 | 66 | unlink(c("test.Rmd", "test.html", "test.md")) 67 | } 68 | \seealso{ 69 | \code{\link{knit}}, \code{markdown::\link[markdown]{mark_html}} 70 | } 71 | -------------------------------------------------------------------------------- /man/knit2pandoc.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils-conversion.R 3 | \name{knit2pandoc} 4 | \alias{knit2pandoc} 5 | \title{Convert various input files to various output files using \code{knit()} and 6 | Pandoc} 7 | \usage{ 8 | knit2pandoc( 9 | input, 10 | output = NULL, 11 | tangle = FALSE, 12 | text = NULL, 13 | quiet = FALSE, 14 | envir = parent.frame(), 15 | to = "html", 16 | pandoc_wrapper = NULL, 17 | ..., 18 | encoding = "UTF-8" 19 | ) 20 | } 21 | \arguments{ 22 | \item{input}{Path to the input file.} 23 | 24 | \item{output}{Path to the output file for \code{knit()}. If \code{NULL}, this 25 | function will try to guess a default, which will be under the current 26 | working directory.} 27 | 28 | \item{tangle}{Boolean; whether to tangle the R code from the input file (like 29 | \code{utils::\link{Stangle}}).} 30 | 31 | \item{text}{A character vector. This is an alternative way to provide the 32 | input file.} 33 | 34 | \item{quiet}{Boolean; suppress the progress bar and messages?} 35 | 36 | \item{envir}{Environment in which code chunks are to be evaluated, for 37 | example, \code{\link{parent.frame}()}, \code{\link{new.env}()}, or 38 | \code{\link{globalenv}()}).} 39 | 40 | \item{to}{Character string giving the Pandoc output format to use.} 41 | 42 | \item{pandoc_wrapper}{An R function used to call Pandoc. If \code{NULL} (the 43 | default), \code{rmarkdown::\link[rmarkdown]{pandoc_convert}()} will be used 44 | if \pkg{rmarkdown} is installed, otherwise \code{\link{pandoc}()}.} 45 | 46 | \item{...}{Options to be passed to the \code{pandoc_wrapper} function.} 47 | 48 | \item{encoding}{Ignored (always assumes UTF-8).} 49 | } 50 | \value{ 51 | Returns the output of the \code{pandoc_wrapper} function. 52 | } 53 | \description{ 54 | Knits the input file and compiles to an output format using Pandoc. 55 | } 56 | \author{ 57 | Trevor L. Davis 58 | } 59 | -------------------------------------------------------------------------------- /man/knit2pdf.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils-conversion.R 3 | \name{knit2pdf} 4 | \alias{knit2pdf} 5 | \title{Convert Rnw or Rrst files to PDF} 6 | \usage{ 7 | knit2pdf( 8 | input, 9 | output = NULL, 10 | compiler = NULL, 11 | envir = parent.frame(), 12 | quiet = FALSE, 13 | ... 14 | ) 15 | } 16 | \arguments{ 17 | \item{input}{Path to the input file.} 18 | 19 | \item{output}{Path to the output file for \code{knit()}. If \code{NULL}, this 20 | function will try to guess a default, which will be under the current 21 | working directory.} 22 | 23 | \item{compiler}{A character string giving the LaTeX engine used to compile 24 | the tex document to PDF. For an Rrst file, setting \code{compiler} to 25 | \code{'rst2pdf'} will use \code{\link{rst2pdf}} to compile the rst file to 26 | PDF using the ReportLab open-source library.} 27 | 28 | \item{envir}{Environment in which code chunks are to be evaluated, for 29 | example, \code{\link{parent.frame}()}, \code{\link{new.env}()}, or 30 | \code{\link{globalenv}()}).} 31 | 32 | \item{quiet}{Boolean; suppress the progress bar and messages?} 33 | 34 | \item{...}{Options to be passed to \code{tinytex::\link[tinytex]{latexmk}()} 35 | or \code{\link{rst2pdf}()}.} 36 | } 37 | \value{ 38 | The filename of the PDF file. 39 | } 40 | \description{ 41 | Knit the input Rnw or Rrst document, and compile to PDF using 42 | \code{tinytex::\link[tinytex]{latexmk}()} or \code{\link{rst2pdf}()}. 43 | } 44 | \note{ 45 | The \code{output} argument specifies the output filename to be passed 46 | to the PDF compiler (e.g. a tex document) instead of the PDF filename. 47 | } 48 | \examples{ 49 | #' compile with xelatex 50 | ## knit2pdf(..., compiler = 'xelatex') 51 | 52 | #' compile a reST file with rst2pdf 53 | ## knit2pdf(..., compiler = 'rst2pdf') 54 | } 55 | \author{ 56 | Ramnath Vaidyanathan, Alex Zvoleff and Yihui Xie 57 | } 58 | -------------------------------------------------------------------------------- /man/knit2wp.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils-conversion.R 3 | \name{knit2wp} 4 | \alias{knit2wp} 5 | \title{Knit an R Markdown document and post it to WordPress} 6 | \usage{ 7 | knit2wp( 8 | input, 9 | title = "A post from knitr", 10 | ..., 11 | envir = parent.frame(), 12 | shortcode = FALSE, 13 | action = c("newPost", "editPost", "newPage"), 14 | postid, 15 | publish = TRUE 16 | ) 17 | } 18 | \arguments{ 19 | \item{input}{Filename of the Rmd document.} 20 | 21 | \item{title}{Title of the post.} 22 | 23 | \item{...}{Other meta information of the post, e.g. \code{categories = c('R', 24 | 'Stats')} and \code{mt_keywords = c('knitr', 'wordpress')}, et cetera.} 25 | 26 | \item{envir}{Environment in which code chunks are to be evaluated, for 27 | example, \code{\link{parent.frame}()}, \code{\link{new.env}()}, or 28 | \code{\link{globalenv}()}).} 29 | 30 | \item{shortcode}{A length-2 logical vector: whether to use the shortcode 31 | \samp{[sourcecode lang='lang']}, which can be useful to WordPress.com users 32 | for syntax highlighting of source code and output. The first element 33 | applies to source code, and the second applies to text output. By default, 34 | both are \code{FALSE}.} 35 | 36 | \item{action}{Whether to create a new post, update an existing post, or 37 | create a new page.} 38 | 39 | \item{postid}{If \code{action} is \code{editPost}, the post id \code{postid} 40 | must be specified.} 41 | 42 | \item{publish}{Boolean: publish the post immediately?} 43 | } 44 | \description{ 45 | This function is a wrapper around the \pkg{RWordPress} package. It compiles 46 | an R Markdown document to HTML and post the results to WordPress. Please note 47 | that \pkg{RWordPress} has not been updated for several years, which is 48 | \href{https://github.com/yihui/knitr/issues/1866}{not a good sign}. For 49 | blogging with R, you may want to try the \pkg{blogdown} package instead. 50 | } 51 | \note{ 52 | This function will convert the encoding of the post and the title to 53 | UTF-8 internally. If you have additional data to send to WordPress (e.g. 54 | keywords and categories), you may have to manually convert them to the 55 | UTF-8 encoding with the \code{\link{iconv}(x, to = 'UTF-8')} function 56 | (especially when using Windows). 57 | } 58 | \examples{ 59 | # see the reference 60 | } 61 | \references{ 62 | \url{https://yihui.org/knitr/demo/wordpress/} 63 | } 64 | \author{ 65 | William K. Morris, Yihui Xie, and Jared Lander 66 | } 67 | -------------------------------------------------------------------------------- /man/knit_child.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/output.R 3 | \name{knit_child} 4 | \alias{knit_child} 5 | \title{Knit a child document} 6 | \usage{ 7 | knit_child(..., options = NULL, envir = knit_global()) 8 | } 9 | \arguments{ 10 | \item{...}{Arguments passed to \code{\link{knit}}.} 11 | 12 | \item{options}{A list of chunk options to be used as global options inside 13 | the child document. When one uses the \code{child} 14 | option in a parent chunk, the chunk options of the parent chunk will be 15 | passed to the \code{options} argument here. Ignored if not a list.} 16 | 17 | \item{envir}{Environment in which code chunks are to be evaluated, for 18 | example, \code{\link{parent.frame}()}, \code{\link{new.env}()}, or 19 | \code{\link{globalenv}()}).} 20 | } 21 | \value{ 22 | A character string of the content of the compiled child document is 23 | returned as a character string so it can be written back to the parent 24 | document directly. 25 | } 26 | \description{ 27 | This function knits a child document and returns a character string to input 28 | the result into the main document. It is designed to be used in the chunk 29 | option \code{child} and serves as the alternative to the 30 | \command{SweaveInput} command in Sweave. 31 | } 32 | \note{ 33 | This function is not supposed be called directly like 34 | \code{\link{knit}()}; instead it must be placed in a parent document to let 35 | \code{\link{knit}()} call it indirectly. 36 | 37 | The path of the child document is determined relative to the parent document. 38 | } 39 | \examples{ 40 | # you can write \Sexpr{knit_child('child-doc.Rnw')} in an Rnw file 'main.Rnw' 41 | # to input results from child-doc.Rnw in main.tex 42 | 43 | # comment out the child doc by \Sexpr{knit_child('child-doc.Rnw', eval = 44 | # FALSE)} 45 | } 46 | \references{ 47 | \url{https://yihui.org/knitr/demo/child/} 48 | } 49 | -------------------------------------------------------------------------------- /man/knit_code.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/parser.R 3 | \docType{data} 4 | \name{knit_code} 5 | \alias{knit_code} 6 | \title{The code manager to manage code in all chunks} 7 | \format{ 8 | An object of class \code{list} of length 7. 9 | } 10 | \usage{ 11 | knit_code 12 | } 13 | \description{ 14 | This object provides methods to manage code (as character vectors) in all 15 | chunks in \pkg{knitr} source documents. For example, 16 | \code{knitr::knit_code$get()} returns a named list of all code chunks (the 17 | names are chunk labels), and \code{knitr::knit_code$get('foo')} returns the 18 | character vector of the code in the chunk with the label \code{foo}. 19 | } 20 | \note{ 21 | The methods on this object include the \code{set()} method (i.e., you 22 | could do something like \code{knitr::knit_code$set(foo = "'my precious new 23 | code'")}), but we recommend that you do not use this method to modify the 24 | content of code chunks, unless you are 25 | \href{https://emitanaka.rbind.io/post/knitr-knitr-code/}{as creative as Emi 26 | Tanaka} and know what you are doing. 27 | } 28 | \keyword{datasets} 29 | -------------------------------------------------------------------------------- /man/knit_engines.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/engine.R 3 | \docType{data} 4 | \name{knit_engines} 5 | \alias{knit_engines} 6 | \title{Engines of other languages} 7 | \format{ 8 | An object of class \code{list} of length 7. 9 | } 10 | \usage{ 11 | knit_engines 12 | } 13 | \description{ 14 | This object controls how to execute the code from languages other than R 15 | (when the chunk option \code{engine} is not \code{'R'}). Each component in 16 | this object is a function that takes a list of current chunk options 17 | (including the source code) and returns a character string to be written into 18 | the output. 19 | } 20 | \details{ 21 | The engine function has one argument \code{options}: the source code of the 22 | current chunk is in \code{options$code}. Usually we can call external 23 | programs to run the code via \code{\link{system2}}. Other chunk options are 24 | also contained in this argument, e.g. \code{options$echo} and 25 | \code{options$eval}, etc. 26 | 27 | In most cases, \code{options$engine} can be directly used in command line to 28 | execute the code, e.g. \code{python} or \code{ruby}, but sometimes we may 29 | want to specify the path of the engine program, in which case we can pass it 30 | through the \code{engine.path} option. For example, \code{engine='ruby', 31 | engine.path='/usr/bin/ruby1.9.1'}. Additional command line arguments can be 32 | passed through \code{options$engine.opts}, e.g. \code{engine='ruby', 33 | engine.opts='-v'}. 34 | 35 | See \code{str(knitr::knit_engines$get())} for a list of built-in language 36 | engines. 37 | } 38 | \note{ 39 | The Leiningen engine \code{lein} requires lein-exec plugin; see 40 | \url{https://github.com/yihui/knitr/issues/1176} for details. 41 | } 42 | \examples{ 43 | knit_engines$get("python") 44 | knit_engines$get("awk") 45 | names(knit_engines$get()) 46 | } 47 | \references{ 48 | Usage: \url{https://yihui.org/knitr/objects/}; examples: 49 | \url{https://yihui.org/knitr/demo/engines/} 50 | } 51 | \keyword{datasets} 52 | -------------------------------------------------------------------------------- /man/knit_exit.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/output.R 3 | \name{knit_exit} 4 | \alias{knit_exit} 5 | \title{Exit knitting early} 6 | \usage{ 7 | knit_exit(append, fully = TRUE) 8 | } 9 | \arguments{ 10 | \item{append}{A character vector to be appended to the results from 11 | \code{knit()} so far. By default, this is \samp{\end{document}} for LaTeX 12 | output, and \samp{} for HTML output, to make the output 13 | document complete. For other types of output, it is an empty string.} 14 | 15 | \item{fully}{Whether to fully exit the knitting process if \code{knit_exit()} 16 | is called from a child document. If \code{FALSE}, only exit the knitting 17 | process of the child document.} 18 | } 19 | \value{ 20 | Invisible \code{NULL}. An internal signal is set up (as a side 21 | effect) to notify \code{knit()} to quit as if it had reached the end of the 22 | document. 23 | } 24 | \description{ 25 | Sometimes we may want to exit the knitting process early, and completely 26 | ignore the rest of the document. This function provides a mechanism to 27 | terminate \code{\link{knit}()}. 28 | } 29 | \examples{ 30 | # see https://github.com/yihui/knitr-examples/blob/master/096-knit-exit.Rmd 31 | } 32 | -------------------------------------------------------------------------------- /man/knit_expand.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/template.R 3 | \name{knit_expand} 4 | \alias{knit_expand} 5 | \title{A simple macro preprocessor for templating purposes} 6 | \usage{ 7 | knit_expand(file, ..., text = read_utf8(file), delim = c("{{", "}}")) 8 | } 9 | \arguments{ 10 | \item{file}{The template file.} 11 | 12 | \item{...}{A list of variables to be used for the code in the template; note that 13 | the variables will be searched for in the parent frame as well.} 14 | 15 | \item{text}{Character vector of lines of code. An alternative way to specify 16 | the template code directly. If \code{text} is provided, \code{file} will be ignored.} 17 | 18 | \item{delim}{A pair of opening and closing delimiters for the templating tags.} 19 | } 20 | \value{ 21 | A character vector, with the tags evaluated and replaced by their 22 | values. 23 | } 24 | \description{ 25 | This function expands a template based on the R expressions in \code{{{}}} 26 | (this tag can be customized by the \code{delim} argument). These expressions 27 | are extracted, evaluated and replaced by their values in the original 28 | template. 29 | } 30 | \examples{ 31 | # see the knit_expand vignette 32 | if (interactive()) browseVignettes(package = "knitr") 33 | } 34 | \references{ 35 | This function was inspired by the pyexpander and m4 36 | (\url{http://www.gnu.org/software/m4/}), thanks to Frank Harrell. 37 | } 38 | -------------------------------------------------------------------------------- /man/knit_filter.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils-vignettes.R 3 | \name{knit_filter} 4 | \alias{knit_filter} 5 | \title{Spell check filter for source documents} 6 | \usage{ 7 | knit_filter(ifile, encoding = "UTF-8") 8 | } 9 | \arguments{ 10 | \item{ifile}{Filename of the source document.} 11 | 12 | \item{encoding}{Ignored (the file \code{ifile} must be encoded in UTF-8).} 13 | } 14 | \value{ 15 | A character vector of the file content, excluding code chunks and 16 | inline expressions. 17 | } 18 | \description{ 19 | When performing spell checking on source documents, we may need to skip R 20 | code chunks and inline R expressions, because many R functions and symbols 21 | are likely to be identified as typos. This function is designed for the 22 | \code{filter} argument of \code{\link{aspell}()} to filter out code chunks 23 | and inline expressions. 24 | } 25 | \examples{ 26 | library(knitr) 27 | knitr_example = function(...) system.file("examples", ..., package = "knitr") 28 | \donttest{ 29 | if (Sys.which("aspell") != "") { 30 | # -t means the TeX mode 31 | utils::aspell(knitr_example("knitr-minimal.Rnw"), knit_filter, control = "-t") 32 | 33 | # -H is the HTML mode 34 | utils::aspell(knitr_example("knitr-minimal.Rmd"), knit_filter, control = "-H -t") 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /man/knit_global.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{knit_global} 4 | \alias{knit_global} 5 | \title{The global environment for evaluating code} 6 | \usage{ 7 | knit_global(envir = NULL) 8 | } 9 | \arguments{ 10 | \item{envir}{If \code{NULL}, the function returns the \code{envir} argument 11 | of \code{\link{knit}}, otherwise it should be a new environment for 12 | evaluating code, in which case the function returns the old environment 13 | after setting the new environment.} 14 | } 15 | \description{ 16 | Get or set the environment in which code chunks are evaluated. 17 | } 18 | -------------------------------------------------------------------------------- /man/knit_hooks.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/hooks.R 3 | \docType{data} 4 | \name{knit_hooks} 5 | \alias{knit_hooks} 6 | \title{Hooks for R code chunks, inline R code and output} 7 | \format{ 8 | An object of class \code{list} of length 7. 9 | } 10 | \usage{ 11 | knit_hooks 12 | } 13 | \description{ 14 | A hook is a function of a pre-defined form (arguments) that takes values of 15 | arguments and returns desired output. The object \code{knit_hooks} is used to 16 | access or set hooks in this package. 17 | } 18 | \examples{ 19 | knit_hooks$get("source") 20 | knit_hooks$get("inline") 21 | } 22 | \references{ 23 | Usage: \url{https://yihui.org/knitr/objects/} 24 | 25 | Components in \code{knit_hooks}: \url{https://yihui.org/knitr/hooks/} 26 | } 27 | \keyword{datasets} 28 | -------------------------------------------------------------------------------- /man/knit_meta.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/output.R 3 | \name{knit_meta} 4 | \alias{knit_meta} 5 | \alias{knit_meta_add} 6 | \title{Metadata about objects to be printed} 7 | \usage{ 8 | knit_meta(class = NULL, clean = TRUE) 9 | 10 | knit_meta_add(meta, label = "") 11 | } 12 | \arguments{ 13 | \item{class}{Optionally return only metadata entries that inherit from the 14 | specified class. The default, \code{NULL}, returns all entries.} 15 | 16 | \item{clean}{Whether to clean the collected metadata. By default, the 17 | metadata stored in \pkg{knitr} is cleaned up once retrieved, because we may 18 | not want the metadata to be passed to the next \code{knit()} call; to be 19 | defensive (i.e. not to have carryover metadata), you can call 20 | \code{knit_meta()} before \code{knit()}.} 21 | 22 | \item{meta}{A metadata object to be added to the session.} 23 | 24 | \item{label}{A chunk label to indicate which chunk the metadata belongs to.} 25 | } 26 | \value{ 27 | \code{knit_meta()} returns the matched metadata specified by 28 | \code{class}; \code{knit_meta_add()} returns all current metadata. 29 | } 30 | \description{ 31 | As an object is printed, \pkg{knitr} will collect metadata about it (if 32 | available). After knitting is done, all the metadata is accessible via this 33 | function. You can manually add metadata to the \pkg{knitr} session via 34 | \code{knit_meta_add()}. 35 | } 36 | -------------------------------------------------------------------------------- /man/knit_params_yaml.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/params.R 3 | \name{knit_params_yaml} 4 | \alias{knit_params_yaml} 5 | \title{Extract knit parameters from YAML text} 6 | \usage{ 7 | knit_params_yaml(yaml, evaluate = TRUE) 8 | } 9 | \arguments{ 10 | \item{yaml}{Character vector containing the YAML text.} 11 | 12 | \item{evaluate}{If \code{TRUE} (the default) expression values 13 | embedded within the YAML will be evaluated. If \code{FALSE}, parameters 14 | defined with an expression will have the parsed but unevaluated expression 15 | in their \code{value} field.} 16 | } 17 | \value{ 18 | List of objects of class \code{knit_param} that correspond to the 19 | parameters declared in the \code{params} section of the YAML. See 20 | \code{\link{knit_params}} for a full description of these objects. 21 | } 22 | \description{ 23 | This function reads the YAML front-matter that has already been extracted 24 | from a document and returns a list of any parameters declared there. 25 | } 26 | \seealso{ 27 | \code{\link{knit_params}} 28 | } 29 | -------------------------------------------------------------------------------- /man/knit_patterns.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/pattern.R 3 | \docType{data} 4 | \name{knit_patterns} 5 | \alias{knit_patterns} 6 | \title{Patterns to match and extract R code in a document} 7 | \format{ 8 | An object of class \code{list} of length 7. 9 | } 10 | \usage{ 11 | knit_patterns 12 | } 13 | \description{ 14 | Patterns are regular expressions and will be used in functions like 15 | \code{base::\link{grep}()} to extract R code and chunk options. The object 16 | \code{knit_patterns} controls the patterns currently used; see the references 17 | and examples for usage. All built-in patterns are available in the list 18 | \link{all_patterns}. 19 | } 20 | \examples{ 21 | library(knitr) 22 | opat = knit_patterns$get() # old pattern list (to restore later) 23 | 24 | apats = all_patterns # a list of all built-in patterns 25 | str(apats) 26 | knit_patterns$set(apats[["rnw"]]) # set pattern list from apats 27 | 28 | knit_patterns$get(c("chunk.begin", "chunk.end", "inline.code")) 29 | 30 | # a customized pattern list; has to empty the original patterns first! 31 | knit_patterns$restore() 32 | # we may want to use this in an HTML document 33 | knit_patterns$set(list(chunk.begin = "")) 34 | str(knit_patterns$get()) 35 | 36 | knit_patterns$set(opat) # put the old patterns back 37 | } 38 | \references{ 39 | Usage: \url{https://yihui.org/knitr/objects/} 40 | 41 | Components in \code{knit_patterns}: \url{https://yihui.org/knitr/patterns/} 42 | } 43 | \seealso{ 44 | \code{\link{all_patterns}} 45 | } 46 | \keyword{datasets} 47 | -------------------------------------------------------------------------------- /man/knit_print.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/output.R 3 | \name{knit_print} 4 | \alias{knit_print} 5 | \alias{normal_print} 6 | \title{A custom printing function} 7 | \usage{ 8 | knit_print(x, ...) 9 | 10 | normal_print(x, ...) 11 | } 12 | \arguments{ 13 | \item{x}{An R object to be printed} 14 | 15 | \item{...}{Additional arguments passed to the S3 method. Currently ignored, 16 | except two optional arguments \code{options} and \code{inline}; see 17 | the references below.} 18 | } 19 | \value{ 20 | The value returned from the print method should be a character vector 21 | or can be converted to a character value. You can wrap the value in 22 | \code{\link{asis_output}()} so that \pkg{knitr} writes the character value 23 | as is in the output. 24 | } 25 | \description{ 26 | The S3 generic function \code{knit_print} is the default printing function in 27 | \pkg{knitr}. The chunk option \code{render} uses this function by default. 28 | The main purpose of this S3 generic function is to customize printing of R 29 | objects in code chunks. We can fall back to the normal printing behavior by 30 | setting the chunk option \code{render = normal_print}. 31 | } 32 | \details{ 33 | Users can write custom methods based on this generic function. For example, 34 | if we want to print all data frames as tables in the output, we can define a 35 | method \code{knit_print.data.frame} that turns a data.frame into a table (the 36 | implementation may use other R packages or functions, e.g. \pkg{xtable} or 37 | \code{\link{kable}()}). 38 | } 39 | \note{ 40 | It is recommended to leave a \code{...} argument in your method, to 41 | allow future changes of the \code{knit_print()} API without breaking your 42 | method. 43 | } 44 | \examples{ 45 | library(knitr) 46 | # write tables for data frames 47 | knit_print.data.frame = function(x, ...) { 48 | res = paste(c("", "", kable(x, output = FALSE)), collapse = "\n") 49 | asis_output(res) 50 | } 51 | # register the method 52 | registerS3method("knit_print", "data.frame", knit_print.data.frame) 53 | # after you define and register the above method, data frames will be printed 54 | # as tables in knitr, which is different with the default print() behavior 55 | } 56 | \references{ 57 | See \code{vignette('knit_print', package = 'knitr')}. 58 | } 59 | -------------------------------------------------------------------------------- /man/knit_rd.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils-rd2html.R 3 | \name{knit_rd} 4 | \alias{knit_rd} 5 | \alias{knit_rd_all} 6 | \title{Knit package documentation} 7 | \usage{ 8 | knit_rd(pkg, links = tools::findHTMLlinks(), frame = TRUE) 9 | 10 | knit_rd_all() 11 | } 12 | \arguments{ 13 | \item{pkg}{Package name.} 14 | 15 | \item{links}{A character vector of links to be passed to 16 | \code{tools::\link{Rd2HTML}()}.} 17 | 18 | \item{frame}{Boolean: whether to put a navigation frame on the left of the 19 | index page.} 20 | } 21 | \value{ 22 | All HTML pages corresponding to topics in the package are written 23 | under the current working directory. An \file{index.html} is also written 24 | as a table of content. 25 | } 26 | \description{ 27 | Run examples in a package and insert output into the examples code; 28 | \code{knit_rd_all()} is a wrapper around \code{knit_rd()} to build static 29 | HTML help pages for all packages under the \file{html} directory of them. 30 | } 31 | \note{ 32 | Ideally the html pages should be put under the \file{html} directory of 33 | an installed package which can be found via \code{system.file('html', 34 | package = 'your_package_name')}, otherwise some links may not work (e.g. 35 | the link to the DESCRITION file). 36 | } 37 | \examples{ 38 | library(knitr) 39 | \dontrun{ 40 | 41 | knit_rd("maps") 42 | knit_rd("rpart") 43 | setwd(system.file("html", package = "ggplot2")) 44 | knit_rd("ggplot2") # time-consuming! 45 | 46 | knit_rd_all() # this may take really long time if you have many packages installed 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /man/knit_theme.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/themes.R 3 | \docType{data} 4 | \name{knit_theme} 5 | \alias{knit_theme} 6 | \title{Syntax highlighting themes} 7 | \format{ 8 | An object of class \code{list} of length 2. 9 | } 10 | \usage{ 11 | knit_theme 12 | } 13 | \description{ 14 | This object can be used to set or get themes in \pkg{knitr} for syntax 15 | highlighting. 16 | } 17 | \details{ 18 | We can use \code{knit_theme$set(theme)} to set the theme, and 19 | \code{knit_theme$get(theme)} to get a theme. The \code{theme} is a character 20 | string for both methods (either the name of the theme, or the path to the CSS 21 | file of a theme), and for the \code{set()} method, it can also be a list 22 | returned by the \code{get()} method. See examples below. 23 | } 24 | \note{ 25 | The syntax highlighting here only applies to \file{.Rnw} (LaTeX) and 26 | \file{.Rhtml} (HTML) documents, and it does not work for other types of 27 | documents, such as \file{.Rmd} (R Markdown, which has its own syntax 28 | highlighting themes; see \url{https://rmarkdown.rstudio.com}). 29 | } 30 | \examples{ 31 | opts_knit$set(out.format = "latex") 32 | knit_theme$set("edit-vim") 33 | 34 | knit_theme$get() # names of all available themes 35 | 36 | thm = knit_theme$get("acid") # parse the theme to a list 37 | knit_theme$set(thm) 38 | 39 | opts_knit$set(out.format = NULL) # restore option 40 | } 41 | \references{ 42 | For a preview of all themes, see 43 | \url{https://gist.github.com/yihui/3422133}. 44 | } 45 | \author{ 46 | Ramnath Vaidyanathan and Yihui Xie 47 | } 48 | \keyword{datasets} 49 | -------------------------------------------------------------------------------- /man/knit_watch.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils-conversion.R 3 | \name{knit_watch} 4 | \alias{knit_watch} 5 | \title{Watch an input file continuously and knit it when it is updated} 6 | \usage{ 7 | knit_watch(input, compile = knit, interval = 1, ...) 8 | } 9 | \arguments{ 10 | \item{input}{An input file path, or a character vector of mutiple input file paths.} 11 | 12 | \item{compile}{A function to compile the \code{input} file. This could be e.g. 13 | \code{\link{knit}} or \code{\link{knit2pdf}}, depending on the input file 14 | and the output you want.} 15 | 16 | \item{interval}{A time interval to pause in each cycle of the infinite loop.} 17 | 18 | \item{...}{Other arguments to be passed to the \code{compile} function.} 19 | } 20 | \description{ 21 | Check the modification time of an input file continously in an infinite loop. 22 | Whenever the time indicates the file has been modified, call a function to 23 | recompile the input file. 24 | } 25 | \details{ 26 | This is actually a general function not necessarily restricted to 27 | applications in \pkg{knitr}. You may specify any \code{compile} function to 28 | process the \code{input} file. To stop the infinite loop, press the 29 | \samp{Escape} key or \samp{Ctrl + C} (depending on your editing environment 30 | and operating system). 31 | } 32 | \examples{ 33 | # knit_watch('foo.Rnw', knit2pdf) 34 | 35 | # knit_watch('foo.Rmd', rmarkdown::render) 36 | } 37 | -------------------------------------------------------------------------------- /man/knitr-package.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/package.R 3 | \docType{package} 4 | \name{knitr-package} 5 | \alias{knitr-package} 6 | \alias{knitr} 7 | \title{A general-purpose tool for dynamic report generation in R} 8 | \description{ 9 | The \pkg{knitr} package is an implementation of Literate Programming, a 10 | programming paradigm that intermingle code chunks (for computing) with prose 11 | (for documentation) in the same document. 12 | } 13 | \details{ 14 | When the document is compiled, the code chunks can be executed, and the 15 | results from computing (text or graphics) are automatically written to the 16 | output along with the prose. 17 | 18 | This package is an alternative tool to Sweave with a more flexible design and 19 | new features like caching and finer control of graphics. It is not limited to 20 | LaTeX and is ready to be customized to process other file formats. See the 21 | package website in the references for more information and examples. 22 | } 23 | \note{ 24 | The pronunciation of \pkg{knitr} is similar to \emph{neater} or you can 25 | think of \emph{knitter} (but it is \emph{single t}). The name comes from 26 | \code{knit} + \code{R} (while \code{Sweave} = \code{S} + \code{weave}). 27 | } 28 | \references{ 29 | Full documentation and demos: \url{https://yihui.org/knitr/}; 30 | FAQ's: \url{https://yihui.org/knitr/faq/} 31 | } 32 | \seealso{ 33 | The core function in this package: \code{\link{knit}}. If you are an 34 | Sweave user, see \code{\link{Sweave2knitr}} on how to convert Sweave files 35 | to \pkg{knitr}. 36 | } 37 | \author{ 38 | Yihui Xie <\url{https://yihui.org}> 39 | } 40 | -------------------------------------------------------------------------------- /man/opts_chunk.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/defaults.R 3 | \docType{data} 4 | \name{opts_chunk} 5 | \alias{opts_chunk} 6 | \alias{opts_current} 7 | \title{Default and current chunk options} 8 | \format{ 9 | An object of class \code{list} of length 7. 10 | 11 | An object of class \code{list} of length 7. 12 | } 13 | \usage{ 14 | opts_chunk 15 | 16 | opts_current 17 | } 18 | \description{ 19 | Options for R code chunks. When running R code, the object \code{opts_chunk} 20 | (default options) is not modified by chunk headers (local chunk options are 21 | merged with default options), whereas \code{opts_current} (current options) 22 | changes with different chunk headers and it always reflects the options for 23 | the current chunk. 24 | } 25 | \details{ 26 | Normally we set up the global options once in the first code chunk in a 27 | document using \code{opts_chunk$set()}, so that all \emph{latter} chunks will 28 | use these options. Note the global options set in one chunk will not affect 29 | the options in this chunk itself, and that is why we often need to set global 30 | options in a separate chunk. 31 | 32 | See \code{str(knitr::opts_chunk$get())} for a list of default chunk options. 33 | } 34 | \note{ 35 | \code{opts_current} should be treated as read-only and you are supposed 36 | to only query its values via \code{opts_current$get()}. Calling 37 | \code{opts_current$set()} will throw an error. 38 | } 39 | \examples{ 40 | opts_chunk$get("prompt") 41 | opts_chunk$get("fig.keep") 42 | } 43 | \references{ 44 | Usage: \url{https://yihui.org/knitr/objects/} 45 | 46 | A list of available options: 47 | \url{https://yihui.org/knitr/options/#chunk-options} 48 | } 49 | \keyword{datasets} 50 | -------------------------------------------------------------------------------- /man/opts_hooks.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/hooks.R 3 | \docType{data} 4 | \name{opts_hooks} 5 | \alias{opts_hooks} 6 | \title{Hooks for code chunk options} 7 | \format{ 8 | An object of class \code{list} of length 7. 9 | } 10 | \usage{ 11 | opts_hooks 12 | } 13 | \description{ 14 | Like \code{\link{knit_hooks}}, this object can be used to set hook functions 15 | to manipulate chunk options. 16 | } 17 | \details{ 18 | For every code chunk, if the chunk option named, say, \code{FOO}, is not 19 | \code{NULL}, and a hook function with the same name has been set via 20 | \code{opts_hooks$set(FOO = function(options) { options })} (you can manipuate 21 | the \code{options} argument in the function and return it), the hook function 22 | will be called to update the chunk options. 23 | } 24 | \examples{ 25 | # make sure the figure width is no smaller than fig.height 26 | opts_hooks$set(fig.width = function(options) { 27 | if (options$fig.width < options$fig.height) { 28 | options$fig.width = options$fig.height 29 | } 30 | options 31 | }) 32 | # remove all hooks 33 | opts_hooks$restore() 34 | } 35 | \references{ 36 | \url{https://yihui.org/knitr/hooks/} 37 | } 38 | \keyword{datasets} 39 | -------------------------------------------------------------------------------- /man/opts_knit.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/defaults.R 3 | \docType{data} 4 | \name{opts_knit} 5 | \alias{opts_knit} 6 | \title{Options for the knitr package} 7 | \format{ 8 | An object of class \code{list} of length 7. 9 | } 10 | \usage{ 11 | opts_knit 12 | } 13 | \description{ 14 | Options including whether to use a progress bar when knitting a document, and 15 | the base directory of images, etc. 16 | } 17 | \details{ 18 | Besides the standard usage (\code{opts_knit$set()}), we can also set package 19 | options prior to loading \code{knitr} or calling \code{knit()} using 20 | \code{\link{options}()} in base R. A global option \code{knitr.package.foo} 21 | in \code{options()} will be set as an option \code{foo} in \code{opts_knit}, 22 | i.e. global options in base R with the prefix \code{knitr.package.} 23 | correspond to options in \code{opts_knit}. This can be useful to set package 24 | options in \file{~/.Rprofile} without loading \pkg{knitr}. 25 | 26 | See \code{str(knitr::opts_knit$get())} for a list of default package options. 27 | } 28 | \examples{ 29 | opts_knit$get("verbose") 30 | opts_knit$set(verbose = TRUE) # change it 31 | if (interactive()) { 32 | # for unnamed chunks, use 'fig' as the figure prefix 33 | opts_knit$set(unnamed.chunk.label = "fig") 34 | knit("001-minimal.Rmd") # from https://github.com/yihui/knitr-examples 35 | } 36 | } 37 | \references{ 38 | Usage: \url{https://yihui.org/knitr/objects/} 39 | 40 | A list of available options: 41 | \url{https://yihui.org/knitr/options/#package-options} 42 | } 43 | \keyword{datasets} 44 | -------------------------------------------------------------------------------- /man/opts_template.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/defaults.R 3 | \docType{data} 4 | \name{opts_template} 5 | \alias{opts_template} 6 | \title{Template for creating reusable chunk options} 7 | \format{ 8 | An object of class \code{list} of length 7. 9 | } 10 | \usage{ 11 | opts_template 12 | } 13 | \description{ 14 | Creates a template binding a label to a set of chunk options. Every chunk 15 | that references the template label will have the specified set of options 16 | applied to it. 17 | } 18 | \examples{ 19 | opts_template$set(myfigures = list(fig.height = 4, fig.width = 4)) 20 | # later you can reuse these chunk options by 'opts.label', e.g. 21 | 22 | # <>= 23 | 24 | # the above is equivalent to <>= 25 | } 26 | \keyword{datasets} 27 | -------------------------------------------------------------------------------- /man/partition_chunk.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/parser.R 3 | \name{partition_chunk} 4 | \alias{partition_chunk} 5 | \title{Partition chunk options from the code chunk body} 6 | \usage{ 7 | partition_chunk(engine, code) 8 | } 9 | \description{ 10 | This is a wrapper function calling \code{xfun::\link[xfun]{divide_chunk}()} 11 | under the hood. 12 | } 13 | \keyword{internal} 14 | -------------------------------------------------------------------------------- /man/pat_fun.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/pattern.R 3 | \name{pat_rnw} 4 | \alias{pat_rnw} 5 | \alias{pat_brew} 6 | \alias{pat_tex} 7 | \alias{pat_html} 8 | \alias{pat_md} 9 | \alias{pat_rst} 10 | \alias{pat_asciidoc} 11 | \alias{pat_textile} 12 | \title{Set regular expressions to read input documents} 13 | \usage{ 14 | pat_rnw() 15 | 16 | pat_brew() 17 | 18 | pat_tex() 19 | 20 | pat_html() 21 | 22 | pat_md() 23 | 24 | pat_rst() 25 | 26 | pat_asciidoc() 27 | 28 | pat_textile() 29 | } 30 | \value{ 31 | The patterns object \code{\link{knit_patterns}} is modified as a side 32 | effect. 33 | } 34 | \description{ 35 | These are convenience functions to set pre-defined pattern lists (the syntax 36 | to read input documents). The function names are built from corresponding 37 | file extensions, e.g. \code{pat_rnw()} can set the Sweave syntax to read Rnw 38 | documents. 39 | } 40 | \examples{ 41 | # see how knit_patterns is modified 42 | knit_patterns$get() 43 | pat_rnw() 44 | knit_patterns$get() 45 | 46 | knit_patterns$restore() # empty the list 47 | } 48 | -------------------------------------------------------------------------------- /man/plot_crop.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plot.R 3 | \name{plot_crop} 4 | \alias{plot_crop} 5 | \title{Crop a plot (remove the edges) using PDFCrop or ImageMagick} 6 | \usage{ 7 | plot_crop(x, quiet = TRUE) 8 | } 9 | \arguments{ 10 | \item{x}{Filename of the plot.} 11 | 12 | \item{quiet}{Whether to suppress standard output from the command.} 13 | } 14 | \value{ 15 | The original filename. 16 | } 17 | \description{ 18 | The program \command{pdfcrop} (often shipped with a LaTeX distribution) is 19 | executed on a PDF plot file, and 20 | \code{magick::\link[magick:transform]{image_trim}()} is executed for other 21 | types of plot files. 22 | } 23 | \details{ 24 | The program \command{pdfcrop} can crop the extra white margins when the plot 25 | format is PDF, to make better use of the space in the output document, 26 | otherwise we often have to struggle with \code{graphics::\link{par}()} to set 27 | appropriate margins. Note \command{pdfcrop} often comes with a LaTeX 28 | distribution such as TinyTeX, MiKTeX, or TeX Live, and you may not need to 29 | install it separately (use \code{Sys.which('pdfcrop')} to check it; if it not 30 | empty, you are able to use it). Note that \command{pdfcrop} depends on 31 | GhostScript. You can check if GhostScript is installed via 32 | \code{tools::find_gs_cmd()}. 33 | } 34 | \references{ 35 | PDFCrop: \url{https://www.ctan.org/pkg/pdfcrop}. If you use 36 | TinyTeX, you may install \command{pdfcrop} with 37 | \code{tinytex::tlmgr_install('pdfcrop')}. 38 | } 39 | -------------------------------------------------------------------------------- /man/rand_seed.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/cache.R 3 | \docType{data} 4 | \name{rand_seed} 5 | \alias{rand_seed} 6 | \title{An unevaluated expression to return .Random.seed if exists} 7 | \usage{ 8 | rand_seed 9 | } 10 | \description{ 11 | This expression returns \code{.Random.seed} when \code{eval(rand_seed)} and 12 | \code{NULL} otherwise. 13 | } 14 | \details{ 15 | It is designed to work with \code{opts_chunk$set(cache.extra = rand_seed)} 16 | for reproducibility of chunks that involve with random number generation. See 17 | references. 18 | } 19 | \examples{ 20 | eval(rand_seed) 21 | rnorm(1) # .Random.seed is created (or modified) 22 | eval(rand_seed) 23 | } 24 | \references{ 25 | \url{https://yihui.org/knitr/demo/cache/} 26 | } 27 | \keyword{datasets} 28 | -------------------------------------------------------------------------------- /man/raw_block.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{raw_block} 4 | \alias{raw_block} 5 | \alias{raw_latex} 6 | \alias{raw_html} 7 | \title{Mark character strings as raw blocks in R Markdown} 8 | \usage{ 9 | raw_block(x, type = "latex", ...) 10 | 11 | raw_latex(x, ...) 12 | 13 | raw_html(x, ...) 14 | } 15 | \arguments{ 16 | \item{x}{The character vector to be protected.} 17 | 18 | \item{type}{The type of raw blocks (i.e., the Pandoc output format). If you 19 | are not sure about the Pandoc output format of your document, insert a code 20 | chunk \code{knitr:::pandoc_to()} and see what it returns after the document 21 | is compiled.} 22 | 23 | \item{...}{Arguments to be passed to \code{\link{asis_output}()}.} 24 | } 25 | \description{ 26 | Wraps content in a raw attribute block, which protects it from being escaped 27 | by Pandoc. See \url{https://pandoc.org/MANUAL.html#generic-raw-attribute}. 28 | Functions \code{raw_latex()} and \code{raw_html()} are shorthands of 29 | \code{raw_block(x, 'latex')} and \code{raw_block(x, 'html')}, respectively. 30 | } 31 | \examples{ 32 | knitr::raw_latex("\\\\emph{some text}") 33 | } 34 | -------------------------------------------------------------------------------- /man/rnw2pdf.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils-conversion.R 3 | \name{rnw2pdf} 4 | \alias{rnw2pdf} 5 | \title{Convert an \file{Rnw} document to PDF} 6 | \usage{ 7 | rnw2pdf( 8 | input, 9 | output = with_ext(input, "pdf"), 10 | compiler = "xelatex", 11 | envir = parent.frame(), 12 | quiet = FALSE, 13 | clean = TRUE, 14 | error = FALSE, 15 | ... 16 | ) 17 | } 18 | \arguments{ 19 | \item{input}{Path to the input file.} 20 | 21 | \item{output}{Path of the PDF output file. By default, it uses the same name 22 | as the \code{input}, but changes the file extension to ".pdf".} 23 | 24 | \item{compiler, ...}{The LaTeX engine and other arguments to be passed to 25 | \code{tinytex::\link[tinytex]{latexmk}()}. The default compiler is 26 | \code{xelatex}.} 27 | 28 | \item{envir}{Environment in which code chunks are to be evaluated, for 29 | example, \code{\link{parent.frame}()}, \code{\link{new.env}()}, or 30 | \code{\link{globalenv}()}).} 31 | 32 | \item{quiet}{Boolean; suppress the progress bar and messages?} 33 | 34 | \item{clean}{If \code{TRUE}, the intermediate files will be removed.} 35 | 36 | \item{error}{If \code{FALSE}, knitting stops when any error occurs.} 37 | } 38 | \value{ 39 | The \code{output} file path. 40 | } 41 | \description{ 42 | Call \code{\link{knit}()} to compile the \file{.Rnw} input to \file{.tex}, 43 | and then \code{tinytex::\link[tinytex]{latexmk}()} to convert \file{.tex} to 44 | \file{.pdf}. 45 | } 46 | \details{ 47 | This function is similar to \code{\link{knit2pdf}()}, with the following differences: 48 | \enumerate{ 49 | \item The default compiler is "xelatex" instead of "pdflatex". 50 | \item \code{output} uses the file extension ".pdf" instead of ".tex". 51 | \item Before knitting, it tries to remove the \code{output} file and will throw a clear error if the file cannot be removed. 52 | \item \code{output} could be under any dir, not necessarily the same directory as \code{input}. 53 | \item It cleans up intermediate files by default, including the ".tex" file. 54 | \item It stops knitting when any error occurs (by setting the chunk option \code{error = FALSE}). 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /man/rocco.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/rocco.R 3 | \name{rocco} 4 | \alias{rocco} 5 | \title{Knit R Markdown using the classic Docco style} 6 | \usage{ 7 | rocco(input, ...) 8 | } 9 | \arguments{ 10 | \item{input}{Path of the input R Markdown file.} 11 | 12 | \item{...}{Arguments to be passed to \code{\link{knit2html}}} 13 | } 14 | \value{ 15 | An HTML file is written, and its name is returned. 16 | } 17 | \description{ 18 | The classic Docco style is a two-column layout, with text in the left and 19 | code in the right column. 20 | } 21 | \details{ 22 | The output HTML page supports resizing and hiding/showing the two columns. 23 | Move the cursor to the center of the page, and it will change to a 24 | bidirectional resize cursor; drag the cursor to resize the two columns. Press 25 | the key \code{t} to hide the code column (show the text column only), and 26 | press again to hide the text column (show code). 27 | } 28 | \examples{ 29 | rocco_view = function(input) { 30 | owd = setwd(tempdir()) 31 | on.exit(setwd(owd)) 32 | if (!file.exists(input)) 33 | return() 34 | o = rocco(input, quiet = TRUE) 35 | if (interactive()) 36 | browseURL(o) 37 | } 38 | # knit these two vignettes using the docco style 39 | rocco_view(system.file("doc", "docco-classic.Rmd", package = "knitr")) 40 | rocco_view(system.file("doc", "knit_expand.Rmd", package = "knitr")) 41 | } 42 | \references{ 43 | The Docco package by Jeremy Ashkenas: 44 | \url{https://github.com/jashkenas/docco} 45 | } 46 | \author{ 47 | Weicheng Zhu and Yihui Xie 48 | } 49 | -------------------------------------------------------------------------------- /man/rst2pdf.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils-conversion.R 3 | \name{rst2pdf} 4 | \alias{rst2pdf} 5 | \title{A wrapper for rst2pdf} 6 | \usage{ 7 | rst2pdf(input, command = "rst2pdf", options = "") 8 | } 9 | \arguments{ 10 | \item{input}{The input rst file.} 11 | 12 | \item{command}{Character string giving the path of the 13 | \command{rst2pdf} program. If the program is not in your PATH, the full path has to be 14 | given here.} 15 | 16 | \item{options}{Extra command line options, e.g. \code{'-v'}.} 17 | } 18 | \value{ 19 | An input file \file{*.rst} will produce \file{*.pdf} and this output 20 | filename is returned if the conversion was successful. 21 | } 22 | \description{ 23 | Convert reST to PDF using \command{rst2pdf} (which converts from rst to PDF 24 | using the ReportLab open-source library). 25 | } 26 | \references{ 27 | \url{https://github.com/rst2pdf/rst2pdf} 28 | } 29 | \seealso{ 30 | \code{\link{knit2pdf}} 31 | } 32 | \author{ 33 | Alex Zvoleff and Yihui Xie 34 | } 35 | -------------------------------------------------------------------------------- /man/set_alias.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/defaults.R 3 | \name{set_alias} 4 | \alias{set_alias} 5 | \title{Set aliases for chunk options} 6 | \usage{ 7 | set_alias(...) 8 | } 9 | \arguments{ 10 | \item{...}{Named arguments. Argument names are aliases, and argument values 11 | are real option names.} 12 | } 13 | \value{ 14 | \code{NULL}. \code{opts_knit$get('aliases')} is modified as the side effect. 15 | } 16 | \description{ 17 | We do not have to use the chunk option names given in \pkg{knitr}; we can set 18 | aliases for them. The aliases are a named character vector; the names are 19 | aliases and the elements in this vector are the real option names. 20 | } 21 | \examples{ 22 | set_alias(w = "fig.width", h = "fig.height") 23 | # then we can use options w and h in chunk headers instead of fig.width and 24 | # fig.height 25 | } 26 | -------------------------------------------------------------------------------- /man/set_header.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/header.R 3 | \name{set_header} 4 | \alias{set_header} 5 | \title{Set the header information} 6 | \usage{ 7 | set_header(...) 8 | } 9 | \arguments{ 10 | \item{...}{Header components; currently possible components are 11 | \code{highlight}, \code{tikz} and \code{framed}, which contain the 12 | necessary commands to be used in the HTML header or LaTeX preamble. Note that 13 | HTML output does not use the \code{tikz} and \code{framed} components, since 14 | they do not make sense in the context of HTML.} 15 | } 16 | \value{ 17 | The header vector in \code{opts_knit} is set. 18 | } 19 | \description{ 20 | Some output documents may need appropriate header information. For example, 21 | for LaTeX output, we need to write \samp{\\usepackage{tikz}} into the 22 | preamble if we use tikz graphics; this function sets the header information 23 | to be written into the output. 24 | } 25 | \details{ 26 | By default, \pkg{knitr} will set up the header automatically. For example, if 27 | the tikz device is used, \pkg{knitr} will add \samp{\\usepackage{tikz}} to 28 | the LaTeX preamble, and this is done by setting the header component 29 | \code{tikz} to be a character string: \code{set_header(tikz = 30 | '\\usepackage{tikz}')}. Similary, when we highlight R code using the 31 | \pkg{highlight} package (i.e. the chunk option \code{highlight = TRUE}), 32 | \pkg{knitr} will set the \code{highlight} component of the header vector 33 | automatically; if the output type is HTML, this component will be different 34 | -- instead of LaTeX commands, it contains CSS definitions. 35 | 36 | For power users, all the components can be modified to adapt to a customized 37 | type of output. For instance, we can change \code{highlight} to LaTeX 38 | definitions of the \pkg{listings} package (and modify the output hooks 39 | accordingly), so we can decorate R code using the \pkg{listings} package. 40 | } 41 | \examples{ 42 | set_header(tikz = "\\\\usepackage{tikz}") 43 | opts_knit$get("header") 44 | } 45 | -------------------------------------------------------------------------------- /man/set_parent.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{set_parent} 4 | \alias{set_parent} 5 | \title{Specify the parent document of child documents} 6 | \usage{ 7 | set_parent(parent) 8 | } 9 | \arguments{ 10 | \item{parent}{Path to the parent document, relative to the current child 11 | document.} 12 | } 13 | \value{ 14 | The preamble is extracted and stored to be used later when the 15 | complete output is written. 16 | } 17 | \description{ 18 | This function extracts the LaTeX preamble of the parent document to use for 19 | the child document, so that the child document can be compiled as an 20 | individual document. 21 | } 22 | \details{ 23 | When the preamble of the parent document also contains code chunks and inline 24 | R code, they will be evaluated as if they were in this child document. For 25 | examples, when \pkg{knitr} hooks or other options are set in the preamble of 26 | the parent document, it will apply to the child document as well. 27 | } 28 | \note{ 29 | Obviously this function is only useful when the output format is LaTeX. 30 | This function only works when the child document is compiled in a 31 | standalone mode using \code{\link{knit}()} (instead of being called in 32 | \code{\link{knit_child}()}); when the parent document is compiled, this 33 | function in the child document will be ignored. 34 | } 35 | \examples{ 36 | ## can use, e.g. \Sexpr{set_parent('parent_doc.Rnw')} or 37 | 38 | # <>= 39 | 40 | # set_parent('parent_doc.Rnw') 41 | 42 | # @ 43 | } 44 | \references{ 45 | \url{https://yihui.org/knitr/demo/child/} 46 | } 47 | -------------------------------------------------------------------------------- /man/sew.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/output.R 3 | \name{sew} 4 | \alias{sew} 5 | \title{Wrap evaluated results for output} 6 | \usage{ 7 | sew(x, options = list(), ...) 8 | } 9 | \arguments{ 10 | \item{x}{Output from \code{evaluate::\link[evaluate]{evaluate}()}.} 11 | 12 | \item{options}{A list of chunk options used to control output.} 13 | 14 | \item{...}{Other arguments to pass to methods.} 15 | } 16 | \description{ 17 | This function is mainly for internal use: it is called on each part of the 18 | output of the code chunk (code, messages, text output, and plots, etc.) after 19 | all statements in the code chunk have been evaluated, and will sew these 20 | pieces of output together into a character vector. 21 | } 22 | -------------------------------------------------------------------------------- /man/spin_child.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/spin.R 3 | \name{spin_child} 4 | \alias{spin_child} 5 | \title{Spin a child R script} 6 | \usage{ 7 | spin_child(input, format) 8 | } 9 | \arguments{ 10 | \item{input}{Filename of the input R script.} 11 | 12 | \item{format}{Passed to \code{format} in \code{spin()}. If not 13 | provided, it will be guessed from the current knitting process.} 14 | } 15 | \value{ 16 | A character string of the knitted R script. 17 | } 18 | \description{ 19 | This function is similar to \code{\link{knit_child}()} but is used in R 20 | scripts instead. When the main R script is not called via 21 | \code{\link{spin}()}, this function simply executes the child script via 22 | \code{\link{sys.source}()}, otherwise it calls \code{\link{spin}()} to spin 23 | the child script into a source document, and uses \code{\link{knit_child}()} 24 | to compile it. You can call this function in R code, or using the syntax of 25 | inline R expressions in \code{\link{spin}()} (e.g. 26 | \code{{{knitr::spin_child('script.R')}}}). 27 | } 28 | -------------------------------------------------------------------------------- /man/vignette_engines.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils-vignettes.R 3 | \name{vignette_engines} 4 | \alias{vignette_engines} 5 | \title{Package vignette engines} 6 | \description{ 7 | Since R 3.0.0, package vignettes can use non-Sweave engines, and \pkg{knitr} 8 | has provided a few engines to compile vignettes via \code{\link{knit}()} with 9 | different templates. See \url{https://yihui.org/knitr/demo/vignette/} for 10 | more information. 11 | } 12 | \note{ 13 | If you use the \code{knitr::rmarkdown} engine, please make sure that 14 | you put \pkg{rmarkdown} in the \samp{Suggests} field of your 15 | \file{DESCRIPTION} file. Also make sure \command{pandoc} is available 16 | during \command{R CMD build}. If you build your package from RStudio, this 17 | is normally not a problem. If you build the package outside RStudio, run 18 | \code{rmarkdown::find_pandoc()} in an R session to check if Pandoc can be 19 | found. 20 | 21 | When the \pkg{rmarkdown} package is not installed or not available, or 22 | \command{pandoc} cannot be found, the \code{knitr::rmarkdown} engine will 23 | fall back to the \code{knitr::knitr} engine, which uses R Markdown v1 based 24 | on the \pkg{markdown} package. 25 | } 26 | \examples{ 27 | library(knitr) 28 | vig_list = tools::vignetteEngine(package = "knitr") 29 | str(vig_list) 30 | vig_list[["knitr::knitr"]][c("weave", "tangle")] 31 | vig_list[["knitr::knitr_notangle"]][c("weave", "tangle")] 32 | vig_list[["knitr::docco_classic"]][c("weave", "tangle")] 33 | } 34 | -------------------------------------------------------------------------------- /man/wrap_rmd.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{wrap_rmd} 4 | \alias{wrap_rmd} 5 | \title{Wrap long lines in Rmd files} 6 | \usage{ 7 | wrap_rmd(file, width = 80, text = NULL, backup) 8 | } 9 | \arguments{ 10 | \item{file}{The input Rmd file.} 11 | 12 | \item{width}{The expected line width.} 13 | 14 | \item{text}{A character vector of text lines, as an alternative to \code{file}. If 15 | \code{text} is not \code{NULL}, \code{file} is ignored.} 16 | 17 | \item{backup}{Path to back up the original file in case anything goes 18 | wrong. If set to \code{NULL}, no backup is made. The default value is constructed 19 | from \code{file} by adding \code{__} before the base filename.} 20 | } 21 | \value{ 22 | If \code{file} is provided, it is overwritten; if \code{text} is 23 | provided, a character vector is returned. 24 | } 25 | \description{ 26 | This function wraps long paragraphs in an R Markdown file. Other elements are 27 | not wrapped: the YAML preamble, fenced code blocks, section headers and 28 | indented elements. The main reason for wrapping long lines is to make it 29 | easier to review differences in version control. 30 | } 31 | \note{ 32 | Currently it does not wrap blockquotes or lists (ordered or unordered). 33 | This feature may or may not be added in the future. 34 | } 35 | \examples{ 36 | wrap_rmd(text = c("```", "1+1", "```", "- a list item", "> a quote", "", 37 | paste(rep("this is a normal paragraph", 5), collapse = " "))) 38 | } 39 | -------------------------------------------------------------------------------- /man/write_bib.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/citation.R 3 | \name{write_bib} 4 | \alias{write_bib} 5 | \title{Generate BibTeX bibliography databases for R packages} 6 | \usage{ 7 | write_bib(..., prefix = getOption("knitr.bib.prefix", "R-")) 8 | } 9 | \arguments{ 10 | \item{..., prefix}{Arguments passed to \code{xfun::\link[xfun]{pkg_bib}()}.} 11 | } 12 | \description{ 13 | A wrapper function of \code{xfun::pkg_bib()}. 14 | } 15 | -------------------------------------------------------------------------------- /tests/run-all.R: -------------------------------------------------------------------------------- 1 | library(testit) 2 | test_pkg("knitr") 3 | -------------------------------------------------------------------------------- /tests/testit/acid.style: -------------------------------------------------------------------------------- 1 | 2 | Description="Acid" 3 | 4 | Default = { Colour="#000000" } 5 | Canvas = { Colour="#eeeeee" } 6 | Number = { Colour="#800080", Bold=true } 7 | Escape = { Colour="#ff00ff", Bold=true } 8 | String = { Colour="#a68500" } 9 | StringPreProc = { Colour="#0000ff" } 10 | BlockComment = { Colour="#ff8000" } 11 | LineComment = { Colour="#f27900" } 12 | PreProcessor = { Colour="#0080c0", Bold=true } 13 | LineNum = { Colour="#303030" } 14 | Operator = { Colour="#ff0080", Bold=true } 15 | Interpolation = { Colour="#9E5DFF" } 16 | 17 | Keywords = { 18 | { Colour= "#bb7977", Bold=true }, 19 | { Colour= "#8080c0", Bold=true }, 20 | { Colour= "#0080c0" }, 21 | { Colour= "#004466" }, 22 | } 23 | 24 | -------------------------------------------------------------------------------- /tests/testit/knit-envir.Rmd: -------------------------------------------------------------------------------- 1 | Test the `envir` argument of `knit()`. 2 | 3 | ```{r test, error=FALSE} 4 | asdfqwerzxcv=1 5 | y 6 | z+9 7 | ``` 8 | -------------------------------------------------------------------------------- /tests/testit/knit-handlers.Rmd: -------------------------------------------------------------------------------- 1 | Test the `calling.handlers` option. 2 | 3 | ```{r} 4 | knitr::opts_chunk$set( 5 | calling.handlers = list(error = hnd) 6 | ) 7 | ``` 8 | 9 | ```{r test, error = TRUE} 10 | 1 + "" 11 | ``` 12 | -------------------------------------------------------------------------------- /tests/testit/knit-tikzDevice.Rnw: -------------------------------------------------------------------------------- 1 | \documentclass[12pt]{article} 2 | \begin{document} 3 | <>= 4 | plot(runif(100), ylab = 'random %') 5 | @ 6 | \end{document} 7 | -------------------------------------------------------------------------------- /tests/testit/test-block.R: -------------------------------------------------------------------------------- 1 | library(testit) 2 | 3 | # see http://stackoverflow.com/q/18992260/559676 for the bug 4 | assert('inline_exec only accept character result', { 5 | block = list(code = "function() 1", input = "inline `r function() 1`") 6 | res = xfun::try_silent(inline_exec(block, new.env())) 7 | (inherits(res, 'try-error')) 8 | block = list(code = "(function() 1)()", input = "inline `r (function() 1)()`") 9 | block$location = matrix(c(8,27), ncol = 2, byrow = TRUE) 10 | res = inline_exec(block, new.env()) 11 | (res %==% "inline 1") 12 | block = list(code = character(0), input = "no inline") 13 | res = inline_exec(block, new.env()) 14 | (res %==% "no inline") 15 | }) 16 | 17 | assert('label_code correct adds comment on code for yaml block or parsed param', { 18 | oldW = getOption('width') 19 | options(width = 20) 20 | (label_code("1+1", list(params.src = "test, eval=TRUE")) %==% "## ----test, eval=TRUE----\n1+1\n") 21 | options(width = oldW) 22 | (label_code("1+1", list(params.chunk = c("#| label: test", "#| eval: true"))) %==% 23 | "## --------\n#| label: test\n#| eval: true\n1+1\n") 24 | }) 25 | -------------------------------------------------------------------------------- /tests/testit/test-closure.R: -------------------------------------------------------------------------------- 1 | library(testit) 2 | 3 | z = new_defaults(list(a = 1)) 4 | 5 | assert('$set() and $get() methods set/get values', { 6 | (z$get() %==% list(a = 1)) 7 | ({z$set(a = 2); z$get('a')} %==% 2) 8 | ({z$set(b = 'f'); z$get(c('a', 'b'))} %==% list(a = 2, b = 'f')) 9 | }) 10 | 11 | assert('$merge() does not change the object but returns a list of new values', { 12 | ({z$merge(list(b = 'g')); z$get('b')} %==% 'f') 13 | (z$merge(list(b = 'g')) %==% list(a = 2, b = 'g')) 14 | }) 15 | 16 | assert('$get(default=TRUE) returns the initial value', { 17 | (z$get(default = TRUE) %==% list(a = 1)) 18 | }) 19 | 20 | assert('$get(names) keeps the names if drop = FALSE and one or more names do not exist', { 21 | (z$get(c('a', 'c')) %==% list(a = 2, c = NULL)) 22 | (z$get('c') %==% NULL) 23 | (z$get('c', drop = FALSE) %==% list(c = NULL)) 24 | }) 25 | 26 | assert('$delete() deletes keys from the list', { 27 | z$set(b1 = TRUE, b2 = FALSE); z$delete(c('b1', 'b2')) 28 | (intersect(c('b1', 'b2'), names(z$get())) %==% character()) 29 | }) 30 | 31 | assert('$restore() restores to the initial value', { 32 | ({z$restore(); z$get()} %==% list(a = 1)) 33 | }) 34 | 35 | assert('$append() returns appended the chunk option', { 36 | z$set(d = 1) 37 | z$append(d = 2) 38 | (z$get('d') %==% c(1, 2)) 39 | }) 40 | 41 | z = new_defaults() 42 | 43 | # named argument in set() 44 | z$set(a = list(b = 2, c = 'qwer')) 45 | 46 | assert('a named argument of list in $set() method is not treated as a list of options', { 47 | (length(z$get()) %==% 1L) 48 | # unnamed argument in set() 49 | ({z$restore(); z$set(list(b = 2, c = 'qwer')); z$get()} %==% list(b = 2, c = 'qwer')) 50 | }) 51 | -------------------------------------------------------------------------------- /tests/testit/test-envir.R: -------------------------------------------------------------------------------- 1 | library(testit) 2 | 3 | rm(list = ls()) 4 | z = 5 5 | assert('a list can be used as the parent frame for knit()', { 6 | # evaluate in a new environment; should create an object in current envir 7 | (!has_error(with(list(y = 4:8), knit('knit-envir.Rmd', quiet = TRUE)))) 8 | }) 9 | 10 | env = new.env() 11 | env$y = 1:3 12 | knit('knit-envir.Rmd', envir = env, quiet = TRUE) 13 | assert('knit() creates objects in its envir argument', { 14 | (!exists('asdfqwerzxcv')) 15 | (exists('asdfqwerzxcv', envir = env)) 16 | }) 17 | 18 | assert('undefined external objects should cause errors', { 19 | (suppressMessages(has_error(knit('knit-envir.Rmd', quiet = TRUE)))) # y is not found 20 | (!has_error(with(list(y = letters), knit('knit-envir.Rmd', quiet = TRUE)))) 21 | }) 22 | 23 | file.remove('knit-envir.md') 24 | -------------------------------------------------------------------------------- /tests/testit/test-hooks-latex.R: -------------------------------------------------------------------------------- 1 | library(testit) 2 | 3 | assert("alt text is included in LaTeX output", { 4 | # no alt text 5 | (hook_plot_tex('foo.pdf', list(fig.align = 'center', fig.show = 'asis')) %==% 6 | '\n\n{\\centering \\includegraphics{foo} \n\n}\n\n') 7 | 8 | # alt text 9 | (hook_plot_tex('foo.pdf', list(fig.alt = 'Alt', fig.align = 'center', 10 | fig.show = 'asis')) %==% 11 | '\n\n{\\centering \\includegraphics[alt={Alt}]{foo} \n\n}\n\n') 12 | 13 | # with width 14 | (hook_plot_tex('foo.pdf', list(fig.alt = 'Alt', fig.align = 'center', 15 | fig.show = 'asis', out.width = '\\maxwidth')) %==% 16 | '\n\n{\\centering \\includegraphics[width=\\maxwidth,alt={Alt}]{foo} \n\n}\n\n') 17 | }) 18 | -------------------------------------------------------------------------------- /tests/testit/test-patterns.R: -------------------------------------------------------------------------------- 1 | library(testit) 2 | 3 | assert('detect_pattern() automatically detects syntax patterns', { 4 | (detect_pattern('<<>>=') %==% 'rnw') 5 | (detect_pattern('<>=') %==% 'rnw') 6 | (detect_pattern('% begin.rcode') %==% 'tex') 7 | (detect_pattern(' 16 | 17 | We can use the JavaScript library [**simple-datatables**](https://github.com/fiduswriter/simple-datatables/) to generate enhanced tables in HTML. In the example below, we create a table for the `mtcars` data: 18 | 19 | ::: {#mtcars-table} 20 | ```{r cool, print.args=list(data.frame=list(limit=NULL))} 21 | mtcars 22 | ``` 23 | ::: 24 | 25 | Note we assigned an `id` to the table, and next we use the **DataTables** library to initialize the table and you will get an interactive table. 26 | 27 | ```{js} 28 | window.addEventListener('load', () => { 29 | new simpleDatatables.DataTable('#mtcars-table > table'); 30 | }); 31 | ``` 32 | 33 | By comparison, below is an ordinary table: 34 | 35 | ```{r boring} 36 | mtcars 37 | ``` 38 | -------------------------------------------------------------------------------- /vignettes/docco-classic.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: R Markdown with the Docco Classic Style 3 | author: Yihui Xie 4 | date: "`r Sys.Date()`" 5 | --- 6 | 7 | 11 | 12 | ```{r setup, echo=FALSE, results='asis'} 13 | x = readLines('docco-linear.Rmd')[-(1:11)] 14 | x = gsub('linear', 'classic', x) 15 | i = grep('^knitr:::docco_classic', x) 16 | x[i - 1] = '```{r}' 17 | x[i] = 'knitr::rocco' 18 | library(knitr) 19 | cat(knit_child(text = x, quiet = TRUE), sep = '\n') 20 | ``` 21 | 22 | You probably have noticed that you can adjust the widths of the two columns 23 | using your cursor. What is more, press `T` on your keyboard, and see what 24 | happens. 25 | -------------------------------------------------------------------------------- /vignettes/docco-linear.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: R Markdown with the Docco Linear Style 3 | --- 4 | 5 | 9 | 10 | This is an example of Markdown vignettes using the [Docco style](http://ashkenas.com/docco/). 11 | 12 | ## Docco 13 | 14 | To use the Docco style for Markdown vignettes in an R package, you need to 15 | 16 | - add `*.Rmd` files under the `vignettes` directory 17 | - add `Suggests: knitr` and `VignetteBuilder: knitr` to the `DESCRIPTION` file 18 | - specify the vignette engine `\VignetteEngine{knitr::docco_linear}` in the `Rmd` files (inside HTML comments) 19 | 20 | After building and installing the package, you can view vignettes via 21 | 22 | ```r 23 | browseVignettes(package = 'Your_Package') 24 | ``` 25 | 26 | ## Examples 27 | 28 | Below are some code chunks as examples. 29 | 30 | ```{r hello, results='asis'} 31 | cat('_hello_ **markdown**!', '\n') 32 | ``` 33 | 34 | Normally you do not need any chunk options. 35 | 36 | ```{r} 37 | 1+1 38 | 10:1 39 | rnorm(5)^2 40 | strsplit('hello, markdown vignettes', '') 41 | ``` 42 | 43 | Feel free to draw beautiful plots and write math $P(X>x)=\alpha/2$. 44 | 45 | ```{r} 46 | n=300; set.seed(123) 47 | par(mar=c(4,4,.1,.1)) 48 | plot(rnorm(n), rnorm(n), pch=21, cex=5*runif(n), col='white', bg='gray') 49 | ``` 50 | 51 | ## How does it work 52 | 53 | Custom CSS and JS files are passed to `markdown::mark_html()` to style the HTML page: 54 | 55 | ```r 56 | knitr:::docco_linear 57 | ``` 58 | 59 | That is it. 60 | -------------------------------------------------------------------------------- /vignettes/knit_expand.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: Templating with knit_expand() 3 | author: Yihui Xie 4 | date: "`{r} Sys.Date()`" 5 | output: 6 | html: 7 | meta: 8 | css: ["@default"] 9 | --- 10 | 11 | 15 | 16 | A few simple examples: 17 | 18 | ```{r} 19 | library(knitr) 20 | knit_expand(text = 'The value of pi is {{pi}}.') 21 | knit_expand(text = 'The value of a is {{a}}, so a + 1 is {{a+1}}.', a = rnorm(1)) 22 | knit_expand(text = 'The area of a circle with radius {{r}} is {{pi*r^2}}', r = 5) 23 | ``` 24 | 25 | Any number of variables: 26 | 27 | ```{r} 28 | knit_expand(text = 'a is {{a}} and b is {{b}}, with my own pi being {{pi}} instead of {{base::pi}}', a=1, b=2, pi=3) 29 | ``` 30 | 31 | Custom delimiter `<% %>`: 32 | 33 | ```{r} 34 | knit_expand(text = 'I do not like curly braces, so use % with <> instead: a is <% a %>.', a = 8, delim = c("<%", "%>")) 35 | ``` 36 | 37 | The pyexpander delimiter: 38 | 39 | ```{r} 40 | knit_expand(text = 'hello $(LETTERS[24]) and $(pi)!', delim = c("$(", ")")) 41 | ``` 42 | 43 | Arbitrary R code: 44 | 45 | ```{r} 46 | knit_expand(text = 'you cannot see the value of x {{x=rnorm(1)}}but it is indeed created: x = {{x}}') 47 | res = knit_expand(text = c(' x | x^2', '{{x=1:5;paste(sprintf("%2d | %3d", x, x^2), collapse = "\n")}}')) 48 | cat(res) 49 | ``` 50 | 51 | The m4 example: 52 | 53 | ```{r} 54 | res = knit_expand(text = c('{{i=0;h2=function(x){i<<-i+1;sprintf("

%d. %s

", i, x)} }}', 55 | '{{h2("First Section")}}', '{{h2("Second Section")}}', '{{h2("Conclusion")}}', '')) 56 | cat(res) 57 | ``` 58 | 59 | Build regression models based on a template; loop through some variables in `mtcars`: 60 | 61 | ```{r, comment=''} 62 | src = lapply(names(mtcars)[2:5], function(i) { 63 | knit_expand(text=c("# Regression on {{i}}", '```{r lm-{{i}}}', 'lm(mpg~{{i}}, data=mtcars)', '```', '')) 64 | }) 65 | # knit the source 66 | litedown::fuse(unlist(src), 'markdown') 67 | ``` 68 | -------------------------------------------------------------------------------- /vignettes/knitr-html.Rhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 10 | 13 | An R HTML vignette with knitr 14 | 15 | 20 | 21 | 22 | 23 |

This is an R HTML vignette. The file extension is *.Rhtml, and 24 | it has to include a special comment to tell R that this file needs to be 25 | compiled by knitr:

26 | 27 |
<!--
28 | %\VignetteEngine{knitr::knitr}
29 | %\VignetteIndexEntry{The Title of Your Vignette}
30 | -->
31 | 
32 | 33 |

Now you can write R code chunks:

34 | 35 | 40 | 41 |

You can also embed plots, for example:

42 | 43 | 47 | 48 |

For package vignettes, you need to encode images in base64 strings using the 49 | knitr::image_uri() function so that the image files are no longer 50 | needed after the vignette is compiled. For example, you can add this chunk in 51 | the beginning of a vignette:

52 | 53 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /vignettes/knitr-intro.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Not An Introduction to knitr" 3 | author: "Yihui Xie" 4 | date: "`{r} Sys.Date()`" 5 | output: 6 | html: 7 | meta: 8 | css: ["@default"] 9 | vignette: > 10 | %\VignetteEngine{litedown::vignette} 11 | %\VignetteIndexEntry{Not an Introduction to knitr} 12 | --- 13 | 14 | The **knitr** package is an alternative tool to Sweave based on a different 15 | design with more features. This document is not an introduction, but only serves 16 | as a placeholder to guide you to the real manuals, which are available on the 17 | package website (e.g. the [main 18 | manual](https://yihui.org/knitr/demo/manual/) and the [graphics 19 | manual](https://yihui.org/knitr/demo/graphics/) ), and remember to read the help 20 | pages of functions in this package. There is a book "Dynamic Docuemnts with R 21 | and knitr" for this package, too. 22 | 23 | Below are code chunk examples: 24 | 25 | ```{r show-off} 26 | options(digits = 4) 27 | rnorm(20) 28 | fit = lm(dist ~ speed, data = cars) 29 | b = coef(fit) 30 | ``` 31 | 32 | ```{r echo=FALSE} 33 | summary(fit)$coefficients 34 | ``` 35 | 36 | The fitted regression equation is $Y=`{r} b[1]`+`{r} b[2]`x$. 37 | 38 | ```{r graphics, fig.cap='A scatterplot with a regression line.'} 39 | par(mar=c(4, 4, 1, .1)) 40 | plot(cars, pch = 20) 41 | abline(fit, col = 'red') 42 | ``` 43 | 44 | ## References 45 | 46 | ```{r, echo=FALSE, results='asis', warning=FALSE} 47 | print(citation('knitr'), style = 'html') 48 | ``` 49 | -------------------------------------------------------------------------------- /vignettes/knitr-markdown.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: R Markdown Vignettes with litedown 3 | author: Yihui Xie 4 | date: "`{r} Sys.Date()`" 5 | output: 6 | html: 7 | meta: 8 | css: ["@default"] 9 | --- 10 | 11 | 15 | 16 | Before R 3.0.0, only Sweave/PDF vignettes were supported in R. Markdown is gaining popularity over the years due to its simplicity, and R 3.0.0 starts to support package vignettes written in R Markdown. 17 | 18 | > Please note this example is for [litedown](https://cran.r-project.org/package=litedown). If you use [R Markdown v2](https://rmarkdown.rstudio.com), you should use the vignette engine `knitr::rmarkdown` instead of `litedown::vignette`. 19 | 20 | ## Package vignettes 21 | 22 | To enable Markdown vignettes in an R package, you need to 23 | 24 | - add `*.Rmd` files under the `vignettes` directory 25 | - add `VignetteBuilder: litedown` to the `DESCRIPTION` file 26 | - specify the vignette engine `\VignetteEngine{litedown::vignette}` in the `Rmd` files (inside HTML comments) 27 | 28 | ## View vignettes 29 | 30 | And R will load the **litedown** package to build these vignettes to HTML files, and you can see them when you open the HTML help: 31 | 32 | ```{r eval=FALSE} 33 | help(package = 'YourPackage', help_type = 'html') 34 | # or see a standalone list of vignettes 35 | browseVignettes('YourPackage') 36 | ``` 37 | 38 | ## Examples 39 | 40 | Below are some code chunks as examples. 41 | 42 | ```{r hello, results='asis'} 43 | if (TRUE) cat('_hello_ **markdown**!', '\n') 44 | ``` 45 | 46 | Normally you do not need any chunk options. 47 | 48 | ```{r test, collapse=TRUE} 49 | 1+1 50 | 10:1 51 | rnorm(5)^2 52 | strsplit('hello, markdown vignettes', '') 53 | ``` 54 | 55 | Feel free to draw beautiful plots and write math $P(X>x)=\alpha/2$. 56 | 57 | ```{r} 58 | n=300; set.seed(123) 59 | par(mar=c(4,4,.1,.1)) 60 | plot(rnorm(n), rnorm(n), pch=21, cex=5*runif(n), col='white', bg='gray') 61 | ``` 62 | --------------------------------------------------------------------------------