reticulate doesn't respect chunk option fig.process which modifies the path
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 1.8k
- Forks
- 349
- Avg merge
- 5h 13m
- Merged PRs (30d)
- 4
Description
The chunk option fig.process seems to not be respected by reticulate.
I'm using the software carpentries' Rmarkdown template for creating lessons (https://github.com/carpentries/styles). The setup that they have created uses fig.process to modify the figure path to use the document's parent directory. Reticulate does not respect the chunk option and so generated figures end up on the wrong path.
I can work around this but it'd be nice if reticulate uses the chunk option properly.
Rmarkdown that demonstrates the issue:
---
title: '`fig.process` Demo'
---
```{r setup}
fix_fig_path <- function(pth) file.path("..", pth)
knitr::opts_chunk$set(tidy = FALSE, results = "markup", comment = NA,
fig.align = "center", fig.path = "fig/rmd-",
fig.process = fix_fig_path,
fig.width = 8.5, fig.height = 8.5,
fig.retina = 2, echo = TRUE)
```
```{python}
import matplotlib.pyplot as plt
import pandas as pd
```
```{python}
df = pd.DataFrame({
"a": range(10)
})
```
```{python}
df.plot()
```
After knitting, the generated document contains an image reference to fig/rmd-unnamed-chunk-1-1.png but it should be ../fig/rmd-unnamed-chunk-1-1.png.
sessionInfo()
R version 4.0.5 (2021-03-31)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Pop!_OS 20.04 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=de_BE.UTF-8
[4] LC_COLLATE=en_US.UTF-8 LC_MONETARY=de_BE.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=de_BE.UTF-8 LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=de_BE.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] Rcpp_1.0.6 lattice_0.20-44 png_0.1-7 digest_0.6.27 rappdirs_0.3.3
[6] grid_4.0.5 jsonlite_1.7.2 evaluate_0.14 rlang_0.4.11 Matrix_1.3-3
[11] reticulate_1.20 rmarkdown_2.8 tools_4.0.5 xfun_0.23 yaml_2.2.1
[16] compiler_4.0.5 htmltools_0.5.1.1 knitr_1.33
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the supplied R Markdown reproduction with knitr's fig.process option and reticulate's Python chunks. Trace how reticulate handles the generated figure path and compare it with the expected ../fig/rmd-unnamed-chunk-1-1.png reference. Done means the configured fig.process path is respected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, r
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100