0

I tried creating as a reproducible example as possible. This would be the Rmarkdown:

enter image description here

No problems when I knit. I tried rendering it with another script:

library(lubridate)
library(rmarkdown)

setwd(directory_of_markdown)
here <- directory_of_markdown

Sys.setenv(RSTUDIO_PANDOC="C:/Program Files/RStudio/resources/app/bin/quarto/bin/tools")

filename <- "Rendered.html"

rmarkdown::render(
  input = "mtcars.Rmd",
  output_format = "html_document",
  output_file = filename,
  output_dir = here,
  encoding = "UTF-8",
  clean = TRUE,
  quiet = TRUE
)

I get this error:

Quitting from lines 21-22 (mtcars.Rmd) 
Error in dirname(name) : file name conversion problem -- name too long?

I tried creating a reproducible markdown code with Is it possible to copy one (or 2, or 3) code chunks from one R Markdown document to another R Markdown document without copy/pasting? but it deleted the tabset.

In case you prefer:

---
title: "mtcars"
output: html_document
date: "`r Sys.Date()`"
---

{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)


## R Markdown {.tabset}


{r cars}
summary(cars)


### Including Plots

{r, echo=FALSE}
plot(pressure)


### Including Plots


{r pressure, echo=FALSE}
plot(pressure)

Solution:

I changed to Quarto and now it works.

1 Answers1

0

Something went wrong in your output_dir, try the {here} package:

rmarkdown::render(
  input = "mtcars.rmd",
  output_format = "html_document",
  output_file = filename,
  encoding = "UTF-8",
  clean = TRUE,
  quiet = TRUE, 
  output_dir = here::here()
)
Julian
  • 6,586
  • 2
  • 9
  • 33