Skip to content

Releases: yihui/knitr

CHANGES IN knitr VERSION 0.4

25 May 21:33

Choose a tag to compare

NEW FEATURES

  • Sweave concordance was finally implemented: when opts_knit$get('concordance') is TRUE, knitr will write a file named 'input-concordance.tex' which contains the mapping between input Rnw and output tex line numbers; this feature is mainly for (but not limited to) RStudio to provide better error navigations: you can jump from the TeX error message to the Rnw source directly to know where the error comes from (the line number of the source of the error may not be accurate but should be in the ballpark) (#133) (thanks, JJ Allaire and Joe Cheng)
  • if output hooks have been set before calling knit(), they will be respected, i.e. knitr will no longer override them by default hooks; you need to make sure all output hooks are set appropriately, e.g. you can start by render_latex() and change some individual hooks later (#165) (thanks, Andrew Redd)
  • newly created objects in the global environment will also be cached if cache is turned on (cache=TRUE); in previous versions knitr is unaware of objects created in globalenv(), e.g. setGeneric() creates S4 generic functions in globalenv() and knitr was unable to capture them (#138) (thanks, syoh)
  • chunk options dev, fig.ext and dpi can be vectors now; this allows one to save a plot to multiple formats, e.g. <<foo, dev=c('pdf', 'png')>>= creates two files for the same plot: foo.pdf and foo.png (#168) (thanks, MYaseen208)
  • an experimental feature for animations created by FFmpeg in HTML/markdown output when fig.show='animate' (#166) (thanks, gabysbrain)
  • the chunk option fig.cap supports multiple figure captions in LaTeX now, e.g. if a chunk produces two plots, we can use fig.cap = c('first caption', 'second caption') to assign two different captions to them respectively when fig.show = 'asis' (#155) (thanks, Jonathan Kennel)
  • new package option opts_knit$get('upload.fun') which is a function that takes a plot file to upload to a certain host and returns the link to the image; by default it is imgur_upload(), and you can use your own function to upload images to other hosts like Flickr (#159) (thanks, Carl Boettiger)
  • all packages loaded in the current session are also cached, so as long as a package has been loaded previously, it will be available to all following chunks (#160)
  • new chunk option autodep and function build_dep() to build cache dependencies among cached chunks automatically by analyzing object names in all cached chunks; this is a loose alternative to the dependson option (see main manual and ?build_dep for details) (#72) (thanks, Seth Falcon)
  • input and output in knit() are no longer restricted to files; they can be stdin()/stdout() or other types of connections (#162; see #162) (thanks, gabysbrain)
  • as-is output (results='asis') and plots are no longer put in the framed environments because of incompatibilities (#163) (thanks, DCCKC, Murray Logan and Jennym Hutchison)

BUG FIXES

  • for plots in LaTeX output, centering should be done with {\centering } instead of \centering{} (#156) (thanks, Ramnath Vaidyanathan)
  • the recorded plot is a more precise representation of the expected plot now, because the recording device also takes the plot size into consideration (#157) (thanks, Christiaan Klijn and Frank Harrell)
  • format_sci() now correctly formats 0; this function is used for inline R code to format numbers in scientific notation (#161) (thanks, Kihoro J. M.)
  • fixed a bug for the case in which the chunk option only contains the label like <<label=foobar>>=; knitr 0.3 was unable to parse the label correctly (<<foobar>>= is OK) (thanks, Muhammad Yaseen)

MINOR CHANGES

  • imgur_upload() returns the link to the image directly, with the XML list as its attribute (in v0.3 the list was returned)
  • more verbose messages in case of chunk errors: both line numbers of the source and chunk info will be printed

DOCUMENTATION

MISC

CHANGES IN knitr VERSION 0.3

25 May 21:34

Choose a tag to compare

NEW FEATURES

  • a fundamental and important new feature for writing chunk options: they can be written as valid R code now, just like we write function arguments (e.g. echo=c(1, 3, 5), fig.cap="my figure caption"); all options will be parsed and evaluated as R code by default; see http://yihui.name/knitr/options for details (#142) (thanks, Baptiste Auguie)
  • chunk references using <<label>> is supported now (#86); thanks to Kevin R. Coombe and Terry Therneau for the discussion
  • new function run_chunk() to run the code in a specified chunk, which is an alternative to the chunk reference in Sweave; see http://yihui.name/knitr/demo/reference/
  • a executable script knit under system.files('bin', package = 'knitr') which makes it easier to call knitr via command line under *nix (call knit input [output] [--pdf])
  • the inline hooks respect getOption('digits') and getOption('scipen') now (see ?options); numbers returned from inline R code will be formatted according to these two options (see a demo at http://yihui.name/knitr/demo/output/)
  • if you still use old Sweave syntax for chunk options, it is possible to write literal commas in chunk options now -- they have to be escaped by \, e.g. caption=hello\, world; this will be parsed to 'hello, world' as a character string; of course this looks ugly and has limited power, so please please consider the new syntax!
  • knit2pdf() gained another argument compiler which can be used to specify the program to compile the tex document to PDF, such as xelatex (#131) (thanks, Ramnath Vaidyanathan and Dennis Murphy)
  • a new function imgur_upload() to upload images to imgur.com; it can be used in HTML or Markdown hooks so the output is a self-contained document which does not need additional image files; opts_knit$get('upload.fun') can use this function (#66) (thanks, Ramnath Vaidyanathan)
  • a child document can be compiled individually with the LaTeX preamble borrowed automatically from a parent document using a new function set_parent(); see the help page for details (#136) (thanks, Helder Correia)
  • to avoid $$ around numbers in the inline output, we can use I() to protect the numeric inline output, e.g. $x = \Sexpr{I(10^7)}$ gives $x = 10^7$ whereas \Sexpr{10^7} gives $10^7$ (thanks, Kevin Middleton)
  • the listings package is formally supported now (see ?render_listings); the default style is borrowed from Sweavel.sty written by Frank Harrell (#101) (thanks, Frank)
  • new package option cache.extra which allows more objects to affect cache; see http://yihui.name/knitr/demo/cache/ (#134)
  • new package option child.path to specify the search path of child documents relative to the parent document (#141)
  • new package option aliases to set aliases for chunk options; see http://yihui.name/knitr/options (#144)
  • new chunk options fig.cap, fig.scap and fig.lp to write captions, short captions, label prefix for the figure environment in LaTeX (#145) (thanks, Frank Harrell)
  • new package option eval.after to set a character vector of chunk options which should be evaluated after a chunk is executed (thanks, Frank Harrell)
  • a series of convenience functions pat_rnw(), pat_tex(), pat_brew() and pat_html() to set built-in patterns (syntax) to read input

MINOR CHANGES

  • package option eval.opts has been dropped: all options of classes symbol or language will be evaluated, so there is no need to specify which options to evaluate manually; remember, the chunk options are similar to function arguments, so you can use any valid R code there
  • the default value for the output argument in knit() is NULL now, so we can also provide output filenames to stitch() and knit2pdf() (#119)
  • standard LaTeX messages are suppressed when a tikz plot is compiled to PDF so that we can see the knitr process more clearly
  • %\SweaveInput{} will be ignored now (#150)
  • results=asis will no longer affect the chunk hook (in the past, the chunk output was not wrapped in the kframe environment when results=asis); it only affects the output hook now
  • the package website allows comments now

MAJOR CHANGES

  • the starting pattern of normal texts in an Rnw document is ^@\\s*%* instead of ^@\\s*$ now, meaning you can write @ % a comment to end a code chunk (this is consistent with Sweave)
  • the default value of the argument output of knit() will be a filename under the current working directory; in previous versions, the output file will be under the same directory as the input file; this change makes it possible to completely separate the input files and output files into different places, and hopefully will give users better experience in managing a whole collection of files (including child documents): put all source files in one place and output files in another place
  • the package homepage is http://yihui.name/knitr now (the previous URL yihui.github.com/knitr will be automatically redirected to the new address)

BUG FIXES

  • the object opts_current does not give the evaluated version of the current chunk options because it was created before the options are evaluated; this has been fixed and opts_current$get() will give the expected values of options (thanks, Frank Harrell)

MISC

  • number of downloads (https://github.com/yihui/knitr/downloads) of knitr documentation before I removed and updated them on GitHub: c(main = 1300, graphics = 549, themes = 130, beamer = 565, listings = 240, minimal = 160)

CHANGES IN knitr VERSION 0.2

25 May 21:34

Choose a tag to compare

NEW FEATURES

  • added support for including child documents in a main document (like \SweaveInput{} but with different implementations); see http://yihui.name/knitr/demo/child/ (#92)
  • for inline R code, character results are returned as-is now (without \texttt{})
  • new function purl() as a wrapper to knit(..., tangle = TRUE) which extracts R code from the input document (thanks to Dieter Menne's wife who suggested the function name)
  • the error hook applies to inline R code when an error occurs in the inline R code, in which case knitr will not stop by default; instead, it writes the error message into the output (#85)
  • chunk option split also works for HTML output now using <iframe></iframe> (#82)
  • knit() gained an argument text as an alternative to input (#88)
  • new chunk option child to include child documents into the main document (#92)
  • chunk option external defaults to TRUE now (was FALSE by default in the last version)
  • added a new demo to show how to build package vignettes with knitr: http://yihui.name/knitr/demo/vignette/
  • added support to the quartz() device under Mac (#103); now the dev option has more choices (see http://yihui.name/knitr/options)
  • chunk option echo can take a numeric vector to select which R expressions to echo into the output now (#108); see http://yihui.name/knitr/options
  • a new function stitch() which is a convenience function to insert an R script into a template and compile (to quickly create a report
    based on an R script)
  • for a chunk hook to run, the corresponding chunk option no longer has to be TRUE; it can be any non-null values; this enables us to make use of the option value directly instead of only knowing it is TRUE (see http://yihui.name/knitr/demo/cache/ for an example)
  • knit() will no longer writes figure or cache files in the same directory as the input document; instead, these files are written in the current working directory (see ?knit)
  • a new function knit_env() that makes the environment of the current chunk accessible to the user

BUG FIXES

  • the code used to merge global chunk options and local options was buggy for cache; it has been fixed now, so cache is more stable (#105), but users may see previously cached chunks being re-evaluated with this version, which should be regarded as a normal phenomenon, and on the second run, the cached chunks will not be evaluated again
  • fixed a buglet when using both options out.width and out.height in Rnw (#113)

CHANGES IN knitr VERSION 0.1

25 May 21:35

Choose a tag to compare

NEW FEATURES

  • first version of knitr: it covers most features in Sweave, cacheSweave and pgfSweave; see package homepage for documentation and examples: http://yihui.name/knitr/

MISC

  • knitr won an Honorable Mention prize (before it was formally released to CRAN) in the Applications of R in Business Contest hosted by Revolution Analytics: http://bit.ly/wP1Dii http://bit.ly/wDRCPV
  • in this NEWS file, #n means the issue number on GitHub, e.g. #142 is #142