Skip to content

Releases: yihui/knitr

CHANGES IN knitr VERSION 1.11

15 Aug 02:57
Compare
Choose a tag to compare

NEW FEATURES

  • added an argument format.args to kable() to pass arguments to format() mainly to format numeric values, e.g. you can use , as the thousands separator via kable(..., format.args = list(big.mark = ',')) (thanks, @neuwirthe, #1086)
  • added an argument quiet to plot_crop() (thanks, @WastlM, #1034)
  • added !expr and !r support in YAML for knit_params() (#1069)
  • added two language engines mysql and psql (thanks, @beanumber, #1076)

MAJOR CHANGES

  • the two hook functions hook_rgl() and hook_webgl() have been moved from knitr to the rgl package (v0.95.1247) (thanks, @dmurdoch)
  • inline R expressions will always be evaluated; previously, they were not be evaluated if the global chunk option eval = FALSE, and the inline output was ?? (thanks, @bozh, #1046)

BUG FIXES

  • the HTML code generated for FFmpeg animations did not work through Pandoc conversion (thanks, @s-fiebig, #1067)

CHANGES IN knitr VERSION 1.10.5

06 May 16:37
Compare
Choose a tag to compare

MAJOR CHANGES

  • this version is a patch release due to a few changes in handling the params field of the YAML metadata, including
    • the character input passed to yaml::yaml.load() will always be converted to UTF-8 to make sure multibyte characters work in YAML
    • the character output from yaml::yaml.load() will always be marked as UTF-8 (vubiostat/r-yaml#6)
    • y, Y, n, and N will not be treated as booleans (TRUE/FALSE), although they do stand for booleans in the YAML 1.1 spec
    • for purl(), the params field will be correctly written to the R script

CHANGES IN knitr VERSION 1.10

25 Apr 02:00
Compare
Choose a tag to compare

NEW FEATURES

  • added a new chunk option cache.rebuild (default: FALSE) to force knitr to invalidate and rebuild the cache for a chunk when cache.rebuild = TRUE (thanks, @zachary-foster, #995)

  • added a stata engine and improved the existing sas engine (thanks, @Hemken #979, @muschellij2 #984)

  • the Markdown table generated from kable() will use the width of characters to decide how many spaces are needed for padding, which can be useful for wide characters such as CJK characters (normally of width 2 per char) (thanks, @yutannihilation, #985)

  • for language engines, the syntax of R Markdown code chunk headers can be {lang, option=value}` now (e.g. {python} and ````{Rcpp}), which is equivalent to ````{r, engine='lang', option=value}` (thanks, @JanSchulz, #963)

  • added the ... argument to all_labels() to make it possible to filter chunk labels according to local chunk options, e.g. you can use all_labels(engine == 'Rcpp') to find the labels of all code chunks that have the chunk option engine = 'Rcpp', and pass the character vector of labels to ref.label to gather all Rcpp code chunks into a single chunk

  • added a new function knit_params() to extract report parameters from the YAML metadata of R Markdown documents; see ?knit_params for details (thanks, @jjallaire, #997)

  • added support for code chunks inside Markdown blockquotes; see the example below (thanks, @r-gaia-cs, #1022)

    > Here is a quote, followed by a code chunk:
    >
    > ```{r}
    > x = 1:10
    > rev(x^2)
    > ```
    
  • the function current_input() gained a new argument dir = FALSE; when dir = TRUE, the absolute path of the input document is returned (thanks, @klmr, #950)

  • if you set options(knitr.duplicate.label = 'allow') before calling knit(), duplicate labels will be allowed, and an incremental suffix will be appended to the duplicate label, e.g. when there are two non-empty chunks with the same label foo, the second label may be converted to foo-2 automatically; please use this feature only if you understand the consequences (e.g. the plot generated by a chunk foo might be foo-2-1.pdf, which can be surprising) (thanks, @khughitt, #957)

  • added a new language engine named lein to support Clojure (thanks, @kindlychung, #940)

MAJOR CHANGES

  • the minimal required version of R is 3.0.2 now, and you are recommended to use the latest version of R when possible

BUG FIXES

CHANGES IN knitr VERSION 1.9

20 Jan 07:29
Compare
Choose a tag to compare

NEW FEATURES

  • added a new function load_cache() so that we can read an object from a cached code chunk, even if the chunk appears later in the document and the object needs to be used earlier; see the example #114 at https://github.com/yihui/knitr-examples (related to #868)
  • added a new function clean_cache() to clean up the cache files that are probably no longer needed, e.g. after you rename or delete cached code chunks (thanks, @sjmgarnier, #933)
  • knit2wp() can update an existing post or create a page now (thanks, @jaredlander, #916, #917)
  • added an engine stan to support Stan through the rstan package; see http://rpubs.com/jrnold/knitr-stan for an example (thanks, @jrnold, #903)
  • for the tikz engine, the path to the convert utility of ImageMagick can be specified via the chunk option engine.opts, e.g. engine.opts = list(convert = 'path/to/convert') (thanks, @mienkoja, #897)
  • similarly, more command line arguments to convert can be specified via, for example, engine.opts = list(convert.opts = '-density 300') (#896)

MAJOR CHANGES

  • when the chunk option dev = 'png', grDevices::png() is used to record plots, instead of the default PDF null device (thanks, @yixuan, #729)
  • currently R (3.1.2) does not really pass the vignette encoding to vignette engines (which is probably a bug), and knitr vignette engines will assume UTF-8 is the file encoding
  • when the chunk option tidy=FALSE, and eval takes a numeric vector, it used to mean the line numbers of the code chunk; now it means the indices of the R expressions in the code chunk, regardless of tidy=FALSE or TRUE (yihui/knitr-examples#39, thanks, @isomorphisms)

MINOR CHANGES

  • you need to upgrade the rgl package to at least v0.95.1201 if you use the hook function hook_webgl() (thanks, @dmurdoch, #901)
  • for the automatically generated figure caption and label of a figure, the label is placed outside of the caption now, i.e. the format was changed from \caption{\label{}} to \caption{}\label{} (thanks, @dr-moebius, @krlmlr, @ltorgo, #746)

BUG FIXES

  • fixed #898: kable() did not work on matrices with duplicate row names (thanks, @tomaskrehlik)
  • fixed #927: kable() did not work for matrices of zero row and/or zero column (thanks, @hadley)
  • fixed #929: opts_knit$restore() does not restore the animation.fun option (thanks, @julian-gehring)

CHANGES IN knitr VERSION 1.8

11 Nov 20:36
Compare
Choose a tag to compare

NEW FEATURES

  • when using knitr with the rmarkdown package, the internal output hook for plots will be automatically switched to the LaTeX plot hook when necessary; for example, when the chunk options fig.align, out.width, out.height, and/or out.extra are specified, raw LaTeX code will be generated to align/set the size of plots, because there is no support for figure alignment or setting the size in the native Markdown syntax; for Word output, these options are simply ignored (related issues: #626, rstudio/rmarkdown#86, rstudio/rmarkdown#148, rstudio/rmarkdown#303)
  • added a new function fig_chunk() to provide a public API to get the figure filenames produced from code chunks; since knitr 1.7 changed the figure file numbering scheme, it broke documents with hard-coded figure filenames, e.g. for Rnw documents, \includegraphics{foo.pdf} should be \includegraphics{foo-1.pdf} after knitr 1.7, and such problems can be avoided by \includegraphics{\Sexpr{fig_chunk('foo', 'pdf')}} (thanks, @edwardabraham, #870)
  • added an argument escape = TRUE to kable() to escape special characters in LaTeX and HTML tables (thanks, @juba, #852)
  • added a new function knit_filter() to filter out code chunks and inline R expressions; this function can be used as the filter for the spell check function utils::aspell(); see ?knit_filter for examples (#581)
  • added a new function spin_child() to spin child R scripts when we spin() a main script (thanks, @krlmlr, #621)
  • added a new function inline_expr() to help authors write the "source code" of the inline expression, e.g. inline_expr('1+1') generates r 1+1 in R Markdown documents (#890)
  • the cache will attempt to preserve the order in which packages are stored on the search path (thanks, @dgrtwo, #867)
  • added a new argument table.envir to kable() for LaTeX tables only; if the table caption is specified (not NULL), the LaTeX environment table will be used by default (i.e. the table is generated in \begin{table} \end{table}), and you can specify alternative environments via kable(..., table.envir = '???') (thanks, @dalupus, #872)
  • chunk options are supported using the syntax # ---- label, options ---- in the R script passed to stitch() (thanks, @wibeasley, yihui/knitr-examples#35)
  • syntax highlighting for .Rnw and .Rhtml documents can be further customized by setting opts_knit$set(highr.opts = list(markup = cmd_mine)) where cmd_mine is a data frame for the markup argument of highr::hilight() (thanks, @lq, #869)
  • added a new language engine groovy (thanks, @VVeitas, #876)

BUG FIXES

  • fixed #862: the YAML metadata in child R Markdown documents was not correctly removed (thanks, @krlmlr)
  • fixed #874: for the engines dot and tikz, the figure directory will be created recursively (thanks, @WilDoane)
  • fixed #654: sub figures were not aligned correctly in LaTeX when the chunk option fig.align was specified (thanks, @lionandoil)
  • the vignette engine knitr::rmarkdown_notangle did not really work (thanks, @bbolker, http://stackoverflow.com/q/26726388/559676)

CHANGES IN knitr VERSION 1.7

13 Oct 23:17
Compare
Choose a tag to compare

NEW FEATURES

  • added a simple Fortran engine after sitting with John Nash for a few minutes at UseR!2014; now we can use the chunk option engine = 'fortran' to include Fortran code in a source document, which will be compiled and loaded via R CMD SHILIB and dyn.load(), respectively
  • added vignette engines with the suffix _notangle, which have the same weave functions as those engines without this suffix but have disabled the tangle function, meaning there will not be R scripts generated from the vignettes during R CMD build or R CMD check (thanks, Carl Boettiger and Michael Koohafkan, #784)
  • added an argument col.names to kable(), so we can specify different column names (thanks, @jackflibb, #801)
  • added a new output hook called text, and its default value knit_hooks$get('text') is the identity function function(x) x; this hook is applied to the text chunks (recall knit_hooks$get('chunk') is applied to code chunks)
  • added a chunk option fig.showtext to support the showtext package; if fig.showtext = TRUE (which is what you should do if you use the showtext package), showtext::showtext.begin() is called before drawing plots (thanks, @yufree, #799)
  • added a new language engine node for Node.js (thanks, Jake Burkhead, #823)
  • added a package option global.par; if we set opts_knit$set(global.par = TRUE) (by default it is FALSE), the par() settings from the last code chunk will be preserved and applied to the next code chunk (thanks, Jim Winget)
  • language engines also write error messages (if there are any) in the output now (thanks, Fabian Hirschmann, #789)
  • added the envir argument to knit_child() so that users can specify a different environment to evaluate the child documents (thanks, Stéphane Laurent, http://stackoverflow.com/q/24009622/559676)
  • for set_parent(), the lines in the parent document that start with \bibliography are matched and inserted in the child document so LaTeX bibliography also works for the child document (thanks, Mark Heckmann, #819)
  • for the chunk option engine = 'cat', the code chunk can be displayed in the output if the chunk language is specified via engine.opts, e.g. engine.opts = list(lang = 'makefile')

BUG FIXES

  • fixed #779: when the chunk options tidy=FALSE and eval=FALSE, prompt=TRUE did not work for R expressions of multiple lines (thanks, Qijie Zhao)
  • fixed #788: there was no increment in the chunk counter when the code chunks were read through read_chunk(), which may lead to clashes of chunk labels (thanks, Jason Ackman)
  • fixed #790: when chunk A reuses code from chunk B via <<B>>, and only the first line of B is empty, chunk reuse can fail because A sees B as empty (thanks, @kingaa)
  • fixed #791: if one has specified the chunk option dev.args, only pointsize and bg in it can be passed to the default recording device (the pdf() device) (thanks, @M-Russell and @joelgombin)
  • fixed #822: cache.lazy = FALSE did not really work (thanks, Liz Ing-Simmons)
  • fixed rstudio/rmarkdown#205: when R marks the encoding of the input document as latin1, knit() can fail to convert its encoding (thanks, @ripkrizbi)
  • fixed #828: scientific notation for inline numbers did not work in R Markdown v2 when the output format is LaTeX (thanks, @nacnudus)
  • fixed #833: for the LaTeX output format, when fig.cap contains . in {}, the automatic short caption does not work (thanks, Roman Luštrik)
  • fixed #844: when the digits argument is a vector and x is a numeric matrix, kable(x) did not work (thanks, @dmenne, #844)

MAJOR CHANGES

  • the knit() function no longer modifies R's default options(digits) from 7 to 4, since it may lead to confusion especially when printing summary() output; for those who want the old behavior, you must set options(digits = 4) in the beginning of your document (thanks, John Honaker, #777)

  • the figure file numbering scheme has changed: for a chunk with a label foo, its figure files are named as foo-i where i ranges from 1 to n (the total number of plots in this chunk); previously, the figure file was named as foo instead of foo-1 when there was only one plot generated in this chunk, which has a potential bug: consider two chunks named foo and foo2, respectively; foo generates two figures foo1.png and foo2.png, and foo2 generates one figure foo2.png, which will overwrite the second figure generated from the chunk foo (thanks, @kevinushey, @kohske, @kforner, #704, #832)

    You may use the function below to clean up the redundant figure files:

    #' Clean up figure files generated before knitr 1.7
    #' 
    #' This function finds figure files that may be redundant, e.g., knitr <= 1.6 
    #' generates foo.pdf for the chunk foo, and knitr >= 1.7 generates foo-1.pdf. If
    #' both foo.pdf and foo-1.pdf exist, foo.pdf might be redundant.
    #' @param dir the figure directory
    #' @param clean whether to remove the redundant figure files; make sure you take
    #'   a look at the list if files detected before you clean them up
    clean_figures = function(dir = './figure', clean = FALSE) {
      # figure files that do not have a numeric suffix
      old1 = list.files(dir, '[^0-9][.][a-z]{3,4}$', full.names = TRUE)
      # or do not have - before suffix
      old2 = list.files(dir, '[^-][0-9]+[.][a-z]{3,4}$', full.names = TRUE)
      new1 = gsub('(.)([.][a-z]{3,4})$', '\\1-1\\2', old1)
      new2 = gsub('([^-])([0-9]+)([.][a-z]{3,4})$', '\\1-\\2\\3', old2)
      new = c(new1, new2)
      old = c(old1, old2)
      idx = file.exists(new)
      message('Possibly redundant files:')
      cat(paste('rm', paste(old, collapse = ' \\\n')), '\n')
      if (!any(idx)) return()
      if (clean) file.remove(old[idx]) else {
        message('Perhaps you should remove these files:')
        cat(old[idx], sep = '\n')
      }
    }
  • for warnings and errors from code chunks, the call that produced them will be printed as part of the message, e.g. previously an error might just be Error: x must be positive, and now it may be Error in FUN(x = -1): x must be positive (thanks, @jennybc, #846)

  • for the engine coffee (CoffeeScript), the flag -p has been removed from the command line arguments, which means the default behavior of this engine is to evaluate the code, instead of printing JavaScript; if you want the old behavior, you need the chunk option engine.opts = '-p' (thanks, Jake Burkhead, #821)

  • when the chunk option results = 'hold', the text output blocks will be collapsed into a single block (thanks, Gavin Simpson, #798)

  • the video format for animations (when the chunk option fig.show='animate') was changed from OGG to WebM (http://www.webmproject.org), which has many benefits over other formats, especially for the web (thanks, @gaorongchao, #641)

  • the YAML metadata in Markdown child documents will be ignored (only the metadata in the top parent document is preserved)

MINOR CHANGES

  • scientific formatting for inline R output is only applied to objects of which the first class is numeric, e.g. chron::chron() objects will no longer be formatted using scientific notations (thanks, @sanfordweisberg, #806)
  • for R Markdown v2 documents, if the inline R output is formatted using the scientific notation, the output must be put in a math environment, e.g. $r 2e10$

CHANGES IN knitr VERSION 1.6

25 May 06:28
Compare
Choose a tag to compare

NEW FEATURES

  • added Textile (http://txstyle.org) support thanks to Richard Cotton; see the example 105 at https://github.com/yihui/knitr-examples (#623)
  • added an argument inline to spin() so that some R code (by default, code of the form {{code}}) can be treated as inline expressions (thanks, Kirill Müller, #620)
  • added an argument prefix to write_bib() so that we can customize the prefix for bib entries; we can also set options(knitr.bib.prefix = 'a_string') so that write_bib() uses this global option as the default value for prefix (thanks, Michael Friendly)
  • the chunk option dev.args will be passed to the pdf recording device if pdf is also in the chunk option dev (note the recording device can be different with the actual drawing device); for example, you can pass a different pointsize to the PDF recording device (thanks, Felix Klein)
  • intermediate files generated during spin() are deleted by default, this can be overridden by setting the new parameter precious to TRUE (thanks, Kirill Müller, #628)
  • exposed the previously internal chunk option code, which is used to store the source code of a chunk; now users also have control over this option, which means we can programmatically assign source code for a code chunk, e.g. code = capture.output(dump('fivenum', ''))
  • added a new chunk option collapse for Markdown output; if collapse = TRUE, knitr will try to merge the source and output blocks into one block; see example 039 at https://github.com/yihui/knitr-examples (thanks, Hadley Wickham)
  • added a new chunk option fig.retina for better display quality of images in HTML output; for example, the physical size of an image is doubled and its display size is halved when fig.retina = 2
  • added a new chunk option strip.white to trim the white lines in the beginning or end of a source chunk in the output (strip.white = TRUE by default)
  • added a new chunk option render for custom rendering of R objects in the output; by default, the render function is print() (or show() for S4 objects) (thanks, Milan Bouchet-Valat, #484)
  • added a new S3 generic function knit_print(), which is used as the default printing function for R objects in the code output now; users can define custom S3 methods to change the printing behavior of R objects in knitr
  • added a new engine scala for Scala thanks to Simeon Fitch (#640)
  • added a new engine named asis to write the chunk content without processing it; it also respects the chunk options echo and eval -- when either one is FALSE, the chunk will be hidden; this makes it possible to write text conditionally (thanks, Simon, #622)
  • the Haskell engine supports multiline clauses using :set +m now, thanks to Adam Vogt (#633)
  • added a new hook function hook_purl() so that code can be more reliably extracted from input documents; see ?hook_purl for details (#607)
  • exported a function plot_crop() which was used in hook_pdfcrop() in previous versions to crop the white margin of plots
  • added a new chunk option cache.lazy (TRUE/FALSE) to decide whether to save and lazy load objects when cache is enabled; for really large objects, you may need cache.lazy=FALSE (thanks, Dario Strbenac, Scott Simpkins, and Mattrition, #572)
  • added a chunk option cache.comments (TRUE/FALSE) to decide whether updating R comments in a code chunk should invalidate the cache database (thanks, @knokknok, #718)
  • kable() supports alignment for HTML tables now (thanks, Joseph Larmarange, #656 and #683)
  • kable() supports table captions in LaTeX, HTML and Pandoc's Markdown now (thanks, Joseph Larmarange, #687)
  • the digits argument for kable(x) can also be a vector of length ncol(x), in which case the number of digits is set for each column separately, e.g. kable(data.frame(x=rnorm(10), y=rnorm(10)), digits = c(1, 4)) (thanks, @nacnudus, #771)
  • for Markdown tables, kable() gained a new argument padding to specify the inner padding of table cells using spaces (thanks, @gavril0, #699)
  • added a new vignette engine called rmarkdown, which uses rmarkdown::render() to create a package vignette from an R Markdown document; see http://rmarkdown.rstudio.com for more information about the rmarkdown package, and the vignette knit_print.Rmd in knitr for an example (basically you specify \VignetteEngine{knitr::rmarkdown} in your vignette)
  • indentation is preserved when using chunk references <<>>, i.e., if <<>> is indented, the spaces before it will be applied to the code that it refers to (thanks, Terry Therneau)
  • added a chunk option fig.process, which can be set as a function to take the path of a plot and process it, e.g. fig.process = function(x) knitr::plot_crop(x); note the fig.process function must return a character string, such as the path of the figure, which might have been changed inside the function
  • added a chunk option R.options so that we can temporarily set local options() for the current code chunk, and the options will be restored after the chunk (thanks, @r2evans, #764)
  • the argument shortcode in knit2wp() can take a logical vector of length 2 now; the first element determines whether to highlight source code, and the second decides syntax highlighting for text output (thanks, Derek Ogle, #663)
  • Sweave2knitr() will report the line numbers indicating where the Sweave-specific syntax was used (thanks, Kirill Muller, #676)
  • added a function current_input() to return the filename of the input document (thanks, Kate Davis, #701)
  • for Markdown, if n (n >= 3) backticks are detected in the code output, the output will be wrapped in n+1 backticks to make sure the original backticks in the output are not interpreted as the token of fenced code blocks
  • for a chunk hook function, we can use a fourth optional argument name, which takes the value of the hook name, e.g. for knit_hooks$set(foo = hook_foo), hook_foo can be of the form function(before, options, envir, name), where name == 'foo' (thanks, Thell Fowler, #733)
  • all the four arguments before, options, envir, and name for a chunk hook are optional now, e.g. you can define a hook function of the form function(before, options), function(before, name, envir), and so on
  • added two read-only chunk options out.width.px and out.height.px, which are the numbers of pixels calculated from fig.width and fig.height (which have units in inches), respectively, and the chunk options out.width and out.height can override the calculated natural size
  • added a new argument encoding to the pandoc() function to specify the character encoding of the input file(s) (fixed the problem http://stackoverflow.com/q/22198832/559676)

BUG FIXES

  • due to the change in evaluate v0.5, evaluate() may return the raw values of expressions, but the S3 method wrap() does not know how to handle them; now these values are just ignored (thanks, Dan Tenenbaum)
  • fixed a bug for dep_auto() that may occur if old cache files generated from previous versions of knitr are used (thanks, Jeffrey Racine)
  • fixed the bug reported at http://stackoverflow.com/q/19166724/559676: the inline hook did not work well with non-numeric values, e.g. Date (thanks, Waldir Leoncio)
  • infinity is formatted as a symbol in inline LaTeX and HTML modes (thanks, Kirill Müller, #629)
  • kable() did not keep the row name when the data only has one row (thanks, @eev2, #636)
  • kable() did not recycle the align argument correctly (thanks, Adam Cooper, #638)
  • kable() chokes on tables with NA's (thanks, Harlan Harris and Benjamin Schiller, #720)
  • kable() did not work with non-numeric data frames (thanks, @talexand, #702)
  • for Markdown/reST tables, kable() should make sure there are at least one empty line before the table output (thanks, @talexand, #705)
  • fixed a bug related to child documents -- chunk options passed from a parent document may not be restored after the child document exits (thanks, Frank Harrell, http://bit.ly/17yitsD)
  • fixed a bug for hook_rgl() when the chunk option dev is a vector of length greater than one (thanks, Ashley Manton, #703)
  • hook_rgl() did not work with the chunk option fig.cap (thanks, Kohske Takahashi, #700)
  • %\documentclass{} was mistakenly treated as the specification of the document class instead of a comment in a LaTeX document (thanks, Jarad Niemi, #713)

MAJOR CHANGES

  • the default value for the chunk option tidy is FALSE now, which means the R source code in chunks will no longer be reformatted by formatR::tidy.source() by default; this feature must be explicitly turned on by tidy=TRUE, and it has brought a lot of confusion in the past, so it is perhaps a good idea not to reformat the source code by default
  • now we treat the closing mark (e.g. @ in Sweave or the three backticks in R Markdown) as part of the code chunk, instead of the beginning of a text chunk, and a consequence for this change is that knitr no longer adds blank lines to the beginning of the text chunks (thanks, Thell 'Bo' Fowler, #752)
  • inline R expressions will no longer be evaluated in try(), which means errors in inline R code will be emitted immediately
  • the first argument of the plot hook is the filename of the plot now; in previous versions, it was a vector of length 2 (basename and file extension); see ?hook_plot
  • the default value for the format argument in pandoc() has changed: it defaults to the t field in the configuration if found, otherwise it defaults to 'html' (thanks, Kohske Takahashi, #697)
  • in the previous version, we can set options(knitr.foo = value) so that knitr can adjust the package options opts_knit$set(foo = value) before knitting a document; now the prefix for package options has been changed to knitr.package., i.e. we should set options(knitr.package.foo) to achieve opts_knit$set(foo); besides, it is also possible to cha...
Read more

CHANGES IN knitr VERSION 1.5

25 May 21:25
Compare
Choose a tag to compare

NEW FEATURES

  • a new option value results='hold' to flush all text output to the end of a chunk like fig.show='hold' (thanks, Harlan Harris, #593)
  • when cache is enabled, automatic chunk dependencies can be truly automatic now; there is no need to call dep_auto() explicitly, and all we need to do is the chunk option autodep=TRUE; the chunk dependencies will be rebuilt after each chunk, so when new chunks are inserted into the document, knitr can also figure out the new dependencies automatically (thanks, @knokknok, #592)
  • for Sublime Text users, there is a SublimeKnitr package to support LaTeX and Markdown with knitr; thanks, Andrew Heiss (#449) (this is not really a new feature of knitr itself, though)
  • now the chunk options warning and message can also take numeric values as indices to select which warnings/messages to include in the output (thanks, Simon Urbanek, #590)

BUG FIXES

MAJOR CHANGES

  • when the chunk option cache=2, the recorded plots (i.e. display lists) will no longer be cached, and the figure files will be assumed to exist the next time the document is compiled, otherwise the cache will be purged and the chunk needs to be recomputed; this will save some disk space and avoid bugs like #588 (thanks, @knokknok)

MINOR CHANGES

  • the Rnw chunk syntax is more tolerant on chunk headers in the sense that any characters after <<>>= are discarded, e.g. <<echo=TRUE>>===foo will be treated as <<echo=TRUE>>= (thanks, Michael Friendly)
  • knitr:::.onLoad() no longer modifies the PATH variable when /usr/texbin is not in PATH under Mac OS
  • when a message/warning/error contains line breaks, they are preserved and the message will not be re-wrapped (#602, thanks, Tyler Rinker)
  • read_chunk() tolerates white spaces in the end of the chunk headers now (suggested by John Maindonald, #606)
  • for R HTML documents, only the highlight component in opts_knit$get('header') was used in previous versions; now all components except framed and tikz are used; this makes it possible to further customize the HTML header (thanks, Wahlen Neuwirth and Erich Neuwirth)
  • in previous versions, the global option KNITR_WIDTH in R was used to set options(width); now this option is set from opts_knit$get('width'), which has the same default value 75 (#597)

CHANGES IN knitr VERSION 1.4

25 May 21:26
Compare
Choose a tag to compare

NOTE

  • if you are using Windows or Linux, you need to read the news about both versions 1.3 and 1.4, because the version 1.3 did not manage to survive on CRAN

NEW FEATURES

  • the cache system is more granular now: instead of the binary option cache = TRUE / FALSE, we can specify cache = 0, 1, 2, 3 (TRUE indicates 3, and FALSE indicates 0; for 1 and 2, see the documentation for cache: http://yihui.name/knitr/options); this means we may change the chunk options involved only with output rendering (e.g. from echo = TRUE to FALSE, or set fig.cap = 'a new caption') without breaking the cache (thanks, Jeroen Ooms, Clark Kogan, and Roman Lustrik, #396, #536)
  • added two new vignette engines called docco_linear and docco_classic using the Docco styles (http://jashkenas.github.io/docco/); see browseVignettes(package = 'knitr') for examples
  • added a function rocco() to compile R Markdown documents to HTML using the classic Docco style, i.e. a two-column layout, with text on the left and code on the right (thanks, Weicheng Zhu, #577)
  • added an argument comment in spin() to specify comment lines that will be ignored by spin(); by default, the block comment /* comment */ is recognized; thanks, Bryan Hanson http://stackoverflow.com/q/17664401/559676
  • it is possible to set package options prior to loading the knitr package now: for a package option foo, we can set options(knitr.foo = value) so that knitr will opts_knit$set(foo = value) when calling knit(); see ?opts_knit for details (thanks, Zhiguang Zhao)
  • added a new argument ext to the pandoc() function so that users can manually specify the output filename extensions (thanks, baptiste, http://stackoverflow.com/q/17710249/559676)
  • for LaTeX and HTML output, syntax highlighting can be done for languages besides R (e.g. Python, Perl, ...); this is achieved by highr::hi_andre(), so Andre Simon's Highlight must be installed, otherwise knitr will fall back to verbatim output for source code; see https://github.com/yihui/knitr-examples/blob/master/098-highlight-python.Rnw for an example (#495)

MAJOR CHANGES

  • knitr formally depends on the highr package now (for syntax highlighting of LaTeX and HTML)
  • the package option stop_on_error has been deprecated; now it is much easier to specify whether you want to stop on errors or not by using the existing chunk option error; if you want to stop, use error=FALSE; see the documentation for details: http://yihui.name/knitr/options
  • the meanings of the chunk options warning and message when they take the value FALSE have also changed: FALSE means the warnings/messages will be printed in the R console and not recorded; this makes it easier to know when/where the warnings/messages were produced during knit()
  • syntax highlighting and adding prompts are done in the source hook now; in previous versions, they were done in knitr:::wrap.source; now the source hook receives the pure source code instead of syntax highlighted code

MINOR CHANGES

  • for the chunk options set in package option opts_knit$get('eval.after'), they will not be evaluated after a chunk if eval=FALSE for that chunk (#570, thanks, @knokknok)
  • for document formats that produce HTML output, the default graphical device is changed to png only if it is pdf; if the device has been changed to values other than pdf, knitr will no longer modify it internally; when the png device is not available, the svg device will be used instead
  • removed the global option KNITR_PROGRESS, which was introduced to suppress the progress bar, but now we have got knit(..., quiet = TRUE), so this option is redundant

BUG FIXES

CHANGES IN knitr VERSION 1.3

25 May 21:27
Compare
Choose a tag to compare

NEW FEATURES

  • added support for AsciiDoc; see example 089 at https://github.com/yihui/knitr-examples/blob/master/089-minimal.Rasciidoc (thanks, Richard Cotton)
  • added support for reStructuredText vignettes in packages; now *.Rrst documents are recognized as vignettes as well, and they will be compiled to PDF via rst2pdf (#533) (thanks, Trevor L Davis)
  • a new function kable() to produce simple tables; see the vignette datatables in browseVignettes(package = 'knitr') for an application; also see a LaTeX example at https://github.com/yihui/knitr-examples/blob/master/091-knitr-table.Rnw
  • the chunk options fig.width and fig.height are vectorized according to the dev option, e.g. fig.wdith = c(7, 10) and dev = c('pdf', 'png') (#538) (thanks, @baptiste)
  • for purl(), code chunks with the option purl=FALSE will not be included in the R script (#519, thanks, Sebastian)
  • new 'hide' value to the fig.show option; the figures are created but not included in the output document (#532) (thanks, Simon)
  • the sas engine uses the listings output now (#541) and was tweaked for better LaTeX display (#562) (thanks, Nick Salkowski)
  • added a quick and dirty c engine (via R CMD SHLIB); see https://github.com/yihui/knitr-examples/blob/master/090-engine-c.Rmd for an example
  • added a new engine asy for Asymptote, a vector graphics language (http://asymptote.sourceforge.net); see examples 093 at https://github.com/yihui/knitr-examples (thanks, Thibaut Lamadon, #559)
  • added a new engine cat to write the content of a code chunk to a file; see the example 095 at https://github.com/yihui/knitr-examples (thanks, Stephen Eglen)
  • added a new function knit_exit() to allow knit() to exit early as if it had reached the end of the document (#524, thanks, Renaud)
  • the chunk option fig.align also works for Markdown output now, e.g., fig.align = 'center' will center images in HTML via the style attribute of the <img> tag (#387)
  • the argument format in the pandoc() function was vectorized, e.g. we can call pandoc(input, format = c('html', 'latex')) and the input file will be converted to HTML and LaTeX, respectively (#547, thanks, Jeroen Ooms)
  • added an argument options to knit_child() to set global chunk options for child documents; if a parent chunk calls a child document (via the child option), the chunk options of the parent chunk will be used as global options for the child document, e.g. for <<foo, child='bar.Rnw', fig.path='figure/foo-'>>=, the figure path prefix will be figure/foo- in bar.Rnw; see http://stackoverflow.com/q/17514055/559676 for an application
  • eclipse_theme() works with font weight (bold) and font style (italic) now when parsing themes from http://eclipsecolorthemes.org
  • added two package options latex.options.graphicx and latex.options.color to allow customization of LaTeX package options, e.g. opts_knit$set(latex.options.color = 'monochrome') generates \usepackage[monochrome]{color} in the LaTeX output (#546)
  • added a new package option unnamed.chunk.label to set the chunk labels for unnamed chunks, e.g. opts_knit$set(unnamed.chunk.label = 'fig') will generate chunk labels fig-1, fig-2, ... (#555) (thanks, Noam Ross)
  • when knit() is running, a global option knitr.in.progress will be set to TRUE; this allows other package authors (e.g. rCharts and googleVis) to adjust certain package options according to getOption('knitr.in.progress') (thanks, Ramnath V, #564)

BUG FIXES

  • fixed #502: using layout() and par() at the same time under R 3.0.0 may lead to a corrupt plot (thanks, Hong Xu http://tex.stackexchange.com/q/108335/9128)
  • fixed a bug in pandoc(): for single-lettered Pandoc arguments, the values are passed to them after spaces instead of equal signs (reported at http://stackoverflow.com/q/16569010/559676)
  • fixed #542: when a child document has a sub-child document and also uses set_parent(), the LaTeX header will be added to the wrong file (thanks, Johan Toloe)
  • stitch_rmd() was using a wrong R Markdown template
  • fixed #537: misleading error message when the graphical device does not exist (thanks, Scott Kostyshak)
  • fixed a bug in hook_rgl() reported at http://cos.name/cn/topic/110742 (incorrect LaTeX code when fig.align='center' and fig.show='hold')
  • fixed #565: added the envir argument to spin() so that the code is evaluated in the correct environment by default (thanks, @GillesSanMartin)

MAJOR CHANGES

  • purl() will write the chunk headers in # ---- label, opts ---- instead of # @knitr label, opts, i.e. @knitr was changed to four dashes ----; similarly, read_chunk() will use the pattern # ---- label ---- to read external code (the old syntax # @knitr is still preserved for compatibility); the main reason for this change is that RStudio uses four dashes in R comments as section headings, so that it is possible to fold sections of R
  • syntax highlighting is done by the highr package if it has been installed, otherwise the old regular-expression-based syntax highlighting will still be used; the highr package does much better syntax highlighting than the regexp-based approach (#327)
  • the commands for syntax highlighting were changed for compatibility with Andre Simon's Highlight package; this will affect LaTeX and HTML users, e.g. \hlnumber was renamed to \hlnum; cached LaTeX and HTML will have to be rebuilt for the new syntax highlighting commands to work (#470)
  • the argument eval was removed in knit_child(); if we do not want to evaluate a child document, we can set eval=FALSE in its parent chunk
  • the script inst/bin/knit gains an option -o to specify the output filenames for knit() (#525, thanks, Aaron Wolen)
  • the default video format for animations is OGG (it is open and free) instead of MP4 (non-free) now; this means Internet Explorer under Windows may not work with the animations (consider Firefox, Chrome and other modern web browsers)
  • warnings and messages in adjacent output chunks are merged, respectively (#534)
  • when the package option verbose = TRUE, the time stamp will be printed after each chunk using timestamp(), but this will mess up with the R command history, so now knitr uses cat() to write the time stamp (#545) (thanks, @knokknok)
  • the argument base in read_rforge() was removed and hard-coded inside the function instead
  • for Markdown output, the figure filenames no longer allow special characters like spaces, and special characters will be automatically replaced by _; this change will avoid problems when publishing to RPubs from RStudio: if figure paths contain special characters, the figures will not be uploaded (thanks, Sangsoon Woo)

MINOR CHANGES

  • the package vignettes uses \VignetteEngine{knitr::knitr} instead of \VignetteEngine{knitr} so that the next version of R can compile the vignettes out of the box (via R CMD Sweave) and no longer need to build the whole package in order to build the vignettes

MAINTAINENCE

  • the package vignettes were moved to the vignettes directory from inst/doc since the former will be preferred by the future versions of R
  • the testing is done via the testit package now (http://cran.r-project.org/package=testit)

MISC