I use updated quarto
and Rmarkdown
and vtree ‘5.4.6’
:
In the same project and same session:
Rmarkdown
does what quarto
does not:
Rmarkdown
renders vtree(iris, "Species")
and quarto
not (allthough quarto
renders inline)
What could be the problem for this?
See here a reproducible example:
---
title: "test"
author: "Me"
date: '2022-06-18'
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(vtree)
```
## R Markdown
```{r cars}
vtree(iris, "Species")
```
---
title: "Untitled"
format: html
editor: visual
---
## Quarto
```{r}
library(vtree)
vtree(iris, "Species")
```
Quarto works a bit differently than R Markdown as it will run R only for the knitting process, and not for the conversion to output format, here HTML.
From the error message, vtree is writing to file the output in the R session temp folder. This folder is not persistent after the R session is closed, which happens once Quarto have run all the computation output. This means that the png
file does not exists anymore when converting to HTML, hence the no image shown in HTML.
(regarding knitr warning, I believe it is knitr version matter, but that does not change the output).
Looking at vtree::vtree()
function, it seems when knitting to HTML is detected R temp folder is used if none provided. IMO this should ne behave that way and it is an issue in vtree package.
To overcome the issue, you need to not let vtree do the default provide yourself a path. You can do that with folder
argument. So this should work
---
title: "Untitled"
format: html
keep-md: true
---
## Quarto
```{r}
library(vtree)
if (!dir.exists("vtree_save")) dir.create("vtree_save")
vtree(iris, "Species", folder = "vtree_save")
```
I would report an issue in vtree repo about this behavior.