./print/R-knitr, General-purpose package for dynamic report generation in R

[ CVSweb ] [ Homepage ] [ RSS ] [ Required by ] [ Add to tracker ]


Branch: CURRENT, Version: 1.38, Package name: R-knitr-1.38, Maintainer: pkgsrc-users

This package provides a general-purpose tool for dynamic report
generation in R, which can be used to deal with any type of (plain
text) files, including Sweave, HTML, Markdown, reStructuredText,
AsciiDoc, and Textile. R code is evaluated as if it were copied and
pasted in an R terminal thanks to the evaluate package (e.g., we do
not need to explicitly print() plots from ggplot2 or lattice). R code
can be reformatted by the formatR package so that long lines are
automatically wrapped, with indent and spaces added, and comments
preserved. A simple caching mechanism is provided to cache results
from computations for the first time and the computations will be
skipped the next time. Almost all common graphics devices, including
those in base R and add-on packages like Cairo, cairoDevice and
tikzDevice, are built-in with this package and it is straightforward
to switch between devices without writing any special functions. The
width and height as well as alignment of plots in the output document
can be specified in chunk options (the size of plots for graphics
devices is also supported). Multiple plots can be recorded in a single
code chunk, and it is also allowed to rearrange plots to the end of a
chunk or just keep the last plot. Warnings, messages and errors are
written in the output document by default (can be turned off). The
language in code chunks is not restricted to R (there is simple
support to Python and shell scripts, etc). Many features are borrowed
from or inspired by Sweave, cacheSweave, pgfSweave, brew and decumar.


Required to run:
[math/R] [textproc/R-formatR] [textproc/R-stringr] [devel/R-evaluate] [security/R-digest] [textproc/R-markdown] [textproc/R-highr] [textproc/R-yaml] [devel/R-xfun]

Required to build:
[pkgtools/cwrappers]

Master sites: (Expand)


Version history: (Expand)


CVS history: (Expand)


   2022-04-23 16:31:10 by Makoto Fujiwara | Files touched by this commit (1)
Log message:
(print/R-knitr) Update DEPENDS version for R-evaluate>=0.15
   2022-04-23 13:42:58 by Makoto Fujiwara | Files touched by this commit (1)
Log message:
(print/R-knitr) Adding TEST_DEPENDS+, but still missing some
   2022-04-23 04:07:00 by Makoto Fujiwara | Files touched by this commit (2)
Log message:
(print/R-knitr) Updated 1.34 to 1.38

knitr 1.38
-------------------------------------------------------
NEW FEATURES

  * The chunk option file can take a vector of file paths now, i.e., this
    option can be used to read more than one file (e.g., file = c("foo.R",
    "bar.R").

  * Added a new engine named exec (#2073) to execute an arbitrary command on
    the code chunk, e.g.,

    ```{exec, command='Rscript'}
    1 + 1
    ```

    The above code chunk executes the Rscript command with the chunk body as
    its input (which basically means executing the R code in a new R session).
    See the example #124 in the repo https://github.com/yihui/knitr-examples
    for more info.

    There exists several command-based engines in knitr, such as awk, bash,
    perl, go, and dot, etc. This new exec engine provides a general mechanism
    to execute any command that users provide. For example, the code chunk

    ```{bash}
    echo 'Hello world!'
    ```

    is equivalent to the chunk using the exec engine and the bash command:

    ```{exec, command='bash'}
    echo 'Hello world!'
    ```

    With this new engine, we no longer need to provide or maintain other simple
    command-based engines. For example, to support TypeScript (#1833), we only
    need to specify command = 'ts-node' with the exec engine.

    If the command has significant side-effects (e.g., compile source code to
    an executable and run the executable, or generate plots to be included in
    the output), it is also possible to create a new engine based on the exec
    engine. The example #124 in the knitr-examples repo has provided a gcc
    example.

    We'd like to thank @TianyiShi2001 for the inspiration (#1829 #1823 #1833).

  * Added a new engine ditaa based on the exec engine to convert ASCII art
    diagrams to bitmaps via the ditaa command (thanks, @kondziu, #2092).

  * Added two new chunk options, class.chunk and attr.chunk, for R Markdown
    output. These options can enclose the whole chunk output (source and
    results) in a fenced Div. Their syntax follows other chunk options with the
    similar names class.* and attr.* (e.g., class.source and attr.source). For
    example, class.chunk = "foo" would wrap the chunk output inside \ 
::: {.foo}
    and ::: (thanks, @atusy, #2099).

  * Added a new chunk option lang to set the language name of a code chunk. By
    default, the language name is the engine name. This is primarily useful for
    syntax highlighting the source chunks in Markdown-based output. Previously
    the lang option was only available to a few engines such as verbatim and
    embed. Now it is available to all engines.

  * Added a new wrapper function rnw2pdf(). It allows users to specify an
    arbitrary output file path, clean the intermediate files, and stop when any
    error occurs in knitting (thanks, @shrektan, #2113).

  * New calling.handlers option for opts_chunk$set() to register calling
    handlers within chunks. See ?evaluate::new_output_handler for details.

MAJOR CHANGES

  * The minimal required version of R was bumped from 3.2.3 to 3.3.0 (thanks,
    @essemenoff, #2100).

  * The working directory under which chunk options are evaluated has been
    changed to the directory of the source document by default. If the package
    option root.dir is set to a different directory, that directory will be
    used as the working directory (#2081).

  * include_graphics() will expand ~ in the image paths now and also warn
    against absolute paths (thanks, @kcarnold, #2063).

  * opts_chunk$set() returns values of old chunk options after setting new
    chunk options now, instead of returning NULL, which can make it a little
    simpler to reset chunk options, e.g., you can temporarily change a few
    chunk options and save them with old = opts_chunk$set(error = FALSE,
    fig.height = 3), and reset them later with opts_chunk$set(old). This works
    for any other objects in knitr that have the $set() methods, such as
    opts_knit, opts_hooks, knit_hooks, knit_engines, and so on.

MINOR CHANGES

  * The chunk option fig.scap has been added to eval.after in opts_knit
    (thanks, @knokknok, #2061).

BUG FIXES

  * Chunk options defined in the #| style are not recognized when the code
    chunk is indented or quoted (thanks, @mine-cetinkaya-rundel, #2086).

  * Fixed a bug in Sweave2knitr() #2097 (thanks, @chroetz).

knitr 1.37
----------------------------------------------------------------
NEW FEATURES

  * Added a new chunk option named file so that the chunk content can be read
    from an external file. Setting the chunk option file = "test.R" is
    equivalent to using the chunk option code = xfun::read_utf8("test.R").

  * For R Markdown documents, code chunks can be embedded in a parent code
    chunk with more backticks now. For example, a code chunk with four
    backticks can contain code chunks with three backticks. One application is
    to conditionally include some verbatim content that contains code chunks
    via the asis engine, e.g.,

    ````{asis, echo=format(Sys.Date(), "%w") == 1}
    Some conditional content only included when report is built on a Monday

    ```{r}
    1 + 1
    ```

    On another day, this content won't be included.
    ````

    Note that the embedded child code chunks (e.g., in the asis chunk above)
    are not parsed or evaluated by knitr, and only the top-level code chunk is
    parsed and evaluated.

  * Added a new engine named comment to comment out content, e.g.,

    ````{comment}
    Arbitrary content to be commented out.

    ```{r}
    1 + 1
    ```

    The above code chunk will not be executed.
    Inline code like `r pi * 5^2` will be ignored, too.
    ````

    Note that if any line of the content to be commented out contains N
    backticks, you will have to use at least N + 1 backticks in the chunk
    header and footer of the comment chunk.

  * Added a new engine named verbatim mainly for R Markdown documents to output
    verbatim content that contains code chunks and/or inline expressions, e.g.,

    ````{verbatim}
    We can output arbitrary content verbatim.

    ```{r}
    1 + 1
    ```

    The content can contain inline code like
    `r pi * 5^2`, too.
    ````

    By default, the verbatim content is placed in a fenced default code block:

    ````default
    We can output arbitrary content verbatim.

    ```{r}
    1 + 1
    ```

    The content can contain inline code like
    `r pi * 5^2`, too.
    ````

    You can change the default language name of the block via the chunk option
    lang, e.g., lang = 'markdown' will output a code block like this:

    ````markdown
    We can output arbitrary content verbatim.

    ```{r}
    1 + 1
    ```

    The content can contain inline code like
    `r pi * 5^2`, too.
    ````

    To disable the language name on the block, use an empty string lang = ''.

    The difference between the verbatim and asis engine is that the former will
    put the content in a fenced code block, and the latter just output the
    content as-is.

    You can also display a file verbatim by using the chunk option file, e.g.,

    ```{verbatim, file="test.Rmd"}
    ```

    This engine also works for other types of documents (e.g., Rnw) but it will
    not allow for nested code chunks within the verbatim code chunk.

  * Added a new engine named embed to embed external plain-text files. It is
    essentially a simple wrapper based on the verbatim engine, with the chunk
    content read from an external file and default language guessed from file
    extension. That is,

    ```{embed, file="foo.R"}
    ```

    is equivalent to

    ```{verbatim, file="foo.R", lang="r"}
    ```

    If you provide the chunk option file to the embed engine, it will read the
    file and show its content verbatim in the output document. Alternatively,
    you can specify the file path in the chunk body, e.g.,

    ```{embed}
    "foo.txt"
    ```

    The quotes are optional but can be helpful for editors (e.g., RStudio IDE)
    to autocomplete the file paths.

    The syntax highlighting language name is from the filename extension by
    default, and you can override it with the chunk option lang (e.g., file =
    "foo.sh", lang = "bash") which is then identical to the \ 
verbatim engine.

BUG FIXES

  * The chunk option child also respects the package option root.dir now
    (thanks, @salim-b, https://community.rstudio.com/t/117563).

  * Fixed a LaTeX error "Package xcolor Error: Undefined color \ 
`fgcolor'" with
    .Rnw documents (thanks, Kurt Hornik).

MINOR CHANGES

  * Improved the (warning) message when unbalanced chunk delimiters are
    detected in R Markdown documents, to make it easier for users to fix the
    problem. The message now contains the line numbers of the opening fence and
    closing fence, as well as the opening and closing backticks. For example,
    the opening fence may be "````{r}" (four backticks) but the \ 
closing fence
    is "```" (three backticks---should also be four to match the opening
    fence), or the opening fence is indented " ```{r}" but the closing \ 
fence is
    not "```". Note that this warning message may become an error in the
    future, i.e., unbalanced chunk delimiters will no longer be allowed.

knitr 1.36
-----------------------------------------------
MAJOR CHANGES

  * In knitr 1.35, if the indentation of the closing backticks does not match
    the indentation of the chunk header in an Rmd document, the closing
    backticks would not be treated as closing fence of a code chunk. This
    behavior has been reverted because we have discovered several cases in
    which the indentation was accidental. A warning message will be issued
    instead, and you are still recommended to fix the improper indentation if
    discovered.

BUG FIXES

  * Fixed a regression in knitr 1.31 that caused package vignettes to generate
    (tangle) invalid R scripts (thanks, @t-kalinowski @halldc, #2052).

knitr 1.35
-------------------------------------------------
NEW FEATURES

  * Chunk options can also be written inside a code chunk now after the special
    comment #|, e.g.,

    ```{r}
    #| echo = FALSE, fig.width = 10,
    #| fig.cap = "This is a long caption."

    plot(cars)
    ```

    The main differences between this new syntax and traditional syntax (i.e.,
    chunk options in the chunk header) are: 1) the chunk options can be freely
    wrapped, i.e., you can write them on as many lines as you prefer; 2) you
    can also use the YAML syntax instead of the comma-separated syntax if you
    like, e.g.,

    ```{r}
    #| echo: false
    #| fig.width: 10
    ```

    Chunk options provided inside a code chunk will override options with the
    same names in the chunk header if chunk options are provided in both
    places, e.g.,

    ```{r, echo = TRUE}
    #| echo = FALSE, fig.width = 10
    ```

    The effective chunk options for the above chunk are echo = FALSE and
    fig.width = 10.

MAJOR CHANGES

  * For R Markdown documents, if the chunk header is indented, the closing
    backticks (usually ```) of the chunk must be indented with the same amount
    of spaces (thanks, @atusy, #2047). For example, the following is no longer
    a valid code chunk because the chunk header is indented but the closing
    backticks are not:

     ```{r}
    1 + 1
    ```

    If you see an error "attempt to use zero-length variable name" when
    knitting an Rmd document, it may be because of this change, and you may
    have indented the chunk header by accident. If that is the case, you need
    to remove the extra white spaces before the chunk header.

    The same problem applies to blockquotes, i.e., > before ```. If you quote
    the chunk header, you have to quote the footer as well, e.g.,

    > ```{r}
    1 + 1
    ```

    The above unbalanced code chunk needs to be corrected to:

    > ```{r}
    > 1 + 1
    > ```

    Quoting the chunk body is optional but recommended.

BUG FIXES

  * Fixed a regression in v1.34: now blank lines in code chunks are stripped
    only when collapse = FALSE but no longer stripped by default when collapse
    = TRUE. If you prefer blank lines to be always stripped, set strip.white =
    TRUE globally or on the per chunk basis (thanks, @IndrajeetPatil, rstudio/
    rmarkdown#2220, #2046).

  * In knitr::combine_words(), when words is length 2 and and = "", \ 
sep will
    now be used (thanks, @eitsupi, #2044).

  * For R Markdown documents, if the chunk output contains N backticks, the
    output hook will use N + 1 backticks to wrap the output, so that the N
    verbatim backticks can be correctly preserved (thanks, @atusy, #2047).
   2021-10-26 13:15:15 by Nia Alarie | Files touched by this commit (1670)
Log message:
print: Replace RMD160 checksums with BLAKE2s checksums

All checksums have been double-checked against existing RMD160 and
SHA512 hashes
   2021-10-07 16:52:04 by Nia Alarie | Files touched by this commit (1670)
Log message:
print: Remove SHA1 hashes for distfiles
   2021-09-18 15:40:57 by Makoto Fujiwara | Files touched by this commit (2)
Log message:
(print/R-knitr) Updated 1.33 to 1.34

(https://github.com/yihui/knitr/releases)
@yihui yihui released this Sep 9, 2021

NEW FEATURES

  * Added a package option latex.tilde so that users can customize the tilde
    symbol, e.g., you can set knitr::opts_knit$set(latex.tilde = "\\hlopt{\\
    scriptsize{\\ensuremath{\\sim}}}"). This is because the default tilde is
    too high in the PDF output, and it's often more desirable to use a middle
    tilde instead (thanks, @brry #1992, @jaredlander #492).

  * For the tikz engine, the class options of the standalone document classs
    can be specified via the chunk option engine.opts$classoption (thanks,
    @XiangyunHuang, #1985). The default value is tikz, i.e., \documentclass
    [tikz]{standalone} is used by default.

  * Added the ability to pass additional arguments to dvisvgm when using the
    tikz engine with fig.ext = "svg" by using dvisvgm.opts in engine.opts
    (thanks, @andrewheiss, #2039). Recent versions of dvisvgm now allow you to
    embed fonts into SVG files as base64-encoded WOFF files, so tikz chunks can
    embed fonts using like so: ```{tikz, fig.ext="svg", engine.opts=list
    (dvisvgm.opts = "--font-format=woff")}.

  * Added a new targets engine (ropensci/targets#503, @wlandau). Details:
    https://books.ropensci.org/targets/markdown.html.

  * The chunk option cache.globals can take values TRUE and FALSE now (in
    addition to a character vector). When FALSE, it tries to find all symbols
    in the code chunk, no matter if they are local or global variables. When
    NULL or TRUE, it tries to find all global variables (thanks, @knokknok, #
    1898).

MAJOR CHANGES

  * An error is now thrown when an inline code result is not coercible to
    character. This has always been the assumed behavior but it happens to be
    different in certain formats with unknown automatic coercion. This is now
    enforced to prevent any unexpected output. An inline code expression must
    evaluate to a character vector or an object coercible by as.character() (#
    2006).

  * The markdown package has been moved from Imports to Suggests in knitr's
    DESCRIPTION, which means it is no longer a hard dependency but has become a
    soft dependency of knitr (#1864). One consequence for package developers is
    that if you use the vignette engines based on markdown (such as
    knitr::knitr), you will have to explicitly declare the (soft) dependency on
    markdown, because the implicit dependency through knitr is no longer there.

  * For R packages that use the knitr::rmarkdown engine to build their
    vignettes, rmarkdown must be declared as a dependency in the package
    DESCRIPTION (e.g., in Suggests). Previously, knitr would fall back to using
    the markdown package to build vignettes if rmarkdown is not declared (#1864
    , #2020).

  * write_bib() only uses the first URL if multiple are found in a package (#
    2028).

MINOR CHANGES

  * The attribute data-external="1" will be added to <iframe>s \ 
generated by
    include_url() to prevent Pandoc from embedding the URL as base64 data
    (thanks, @IndrajeetPatil, https://stackoverflow.com/q/67477667/559676).

  * The chunk option strip.white = TRUE used to work only when the chunk option
    collapse = FALSE. Now the two options are independent, i.e., strip.white
    also works when collapse = TRUE (thanks, @kbvernon, #2011).

  * When building R Markdown vignettes but Pandoc is not available, the
    vignette engine will emit a message instead of a warning before falling
    back to using the markdown package.

  * The internal function is_abs_path() has been removed. Users (if any) should
    use the exported function xfun::is_abs_path() instead.

BUG FIXES

  * Fix an issue with the RStudio IDE when using knitr::include_url() or
    knitr::include_app() in interactive Notebook mode. This will no more cause
    an error but print the list object as is (thanks, @systemnova, #2015).

  * Fix a regression with fig.keep chunk option used in chunks with only one
    figure where the figure was not showing in output (thanks, @fmichonneau, #
    1993).

  * Allow vignettes to be tangled (and output compared) in R CMD check if they
    have a corresponding .Rout.save (thanks, @lentinj, #2018).
   2021-06-05 09:30:58 by Makoto Fujiwara | Files touched by this commit (1)
Log message:
(print/R-knitr) Update TEST_DEPENDS+= info, not compelete yet
   2021-06-01 01:56:07 by Makoto Fujiwara | Files touched by this commit (2)
Log message:
(print/R-knitr) Updated 1.23 to 1.33, NEWS.md unknown