Skip to content

CHANGES IN knitr VERSION 0.4

Compare
Choose a tag to compare
@yihui yihui released this 25 May 21:33
· 5531 commits to master since this release

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