Skip to content
Permalink
Browse files

fix the issue reported by @XiangyunHuang at https://d.cosx.org/d/421249

the python engine was from reticulate, and knitr doesn't know when/whether the python code has generated plots, so the chunk option fig.num is empty, then this will error

  if (options$fig.num > 1)
  • Loading branch information
yihui committed Feb 13, 2020
1 parent 6daea79 commit 2e00a48edbb508143ee8941399c3410795ec2b35
Showing with 6 additions and 1 deletion.
  1. +1 −1 DESCRIPTION
  2. +4 −0 NEWS.md
  3. +1 −0 R/output.R
@@ -1,7 +1,7 @@
Package: knitr
Type: Package
Title: A General-Purpose Package for Dynamic Report Generation in R
Version: 1.28.1
Version: 1.28.2
Authors@R: c(
person("Yihui", "Xie", role = c("aut", "cre"), email = "xie@yihui.name", comment = c(ORCID = "0000-0003-0645-5666")),
person("Adam", "Vogt", role = "ctb"),
@@ -4,6 +4,10 @@

- The argument `error` of `include_graphics()` takes value from the global R option `knitr.graphics.error` by default, e.g., you may set `options(knitr.graphics.error = FALSE)` so `include_graphics()` won't signal an error if the graphics file to be included doesn't exist.

## BUG FIXES

- For non-R code chunks that generate plots and use the chunk option `fig.cap`, the `plot` hook in **knitr** stopped working in v1.27 and v1.28 (thanks, @XiangyunHuang, https://d.cosx.org/d/421249).

# CHANGES IN knitr VERSION 1.28

## BUG FIXES
@@ -563,6 +563,7 @@ wrap.knit_image_paths = function(x, options = opts_chunk$get(), inline = FALSE)
if (length(w1) * length(w2) == 1 && is.numeric(w1) && w1 == w2)
options['out.width'] = list(NULL)
}
options$fig.num = options$fig.num %n% length(x)
dpi = attr(x, 'dpi') %n% options$dpi
hook = knit_hooks$get('plot')
paste(unlist(lapply(seq_along(x), function(i) {

1 comment on commit 2e00a48

@XiangyunHuang

This comment has been minimized.

Copy link

XiangyunHuang commented on 2e00a48 Feb 14, 2020

The bug is dead!

Please sign in to comment.
You can’t perform that action at this time.