Error in options[[sprintf("fig.%s", i)]] * options$dpi: ! non-numeric argument to binary operator

Nan Xiao 2023-06-06 1 min read
Rubber duck debugging. Photo by Timothy Dykes.
Rubber duck debugging. Photo by Timothy Dykes.

If Google leads you here, you probably assigned a character value to a knitr chunk option such as fig.width or fig.height that only accepts numeric values, and your are trying to render that R Markdown or Quarto document.

For example, it is easy to make this mistake:

```{r, fig.width="100%"}
plot(1:10)
```

where you probably meant:

```{r, fig.width=6, out.width="100%"}
plot(1:10)
```

That’s all! I hope this helps.