[help] tar_render()
puts the result in a different directory when there is a space in the filename (or not)
#151
-
Help
DescriptionI think that I have found a bug in In the example below, library(targets)
tar_script({
library(targets)
library(tarchetypes)
dir.create("report", showWarnings = FALSE)
rmd_contents <- c("---", "title: \"Untitled\"", "output: pdf_document", "---", "", "# Something here")
writeLines(text = rmd_contents, con = "report/report_1.Rmd", sep = "\n")
writeLines(text = rmd_contents, con = "report/report 2.Rmd", sep = "\n")
list(
tar_render(
report1,
"report/report_1.Rmd"
),
tar_render(
report2,
"report/report 2.Rmd"
)
)
})
tar_make()
#> ▶ start target report1
#> ● built target report1 [2.297 seconds]
#> ▶ start target report2
#> ● built target report2 [3.359 seconds]
#> ▶ end pipeline [5.781 seconds] Created on 2023-06-22 with reprex v2.0.2 |
Beta Was this translation helpful? Give feedback.
Answered by
wlandau
Jun 22, 2023
Replies: 1 comment 1 reply
-
Indeed you may have found a bug, but it is not in tmp <- tempfile()
dir.create(tmp)
setwd(tmp)
dir.create("report", showWarnings = FALSE)
rmd_contents <- c("---", "title: \"Untitled\"", "output: pdf_document", "---", "", "# Something here")
writeLines(text = rmd_contents, con = "report/report_1.Rmd", sep = "\n")
writeLines(text = rmd_contents, con = "report/report 2.Rmd", sep = "\n")
library(rmarkdown)
report1 <- render("report/report_1.Rmd", knit_root_dir = ".")
#> processing file: report_1.Rmd
#> output file: report_1.knit.md
#> /usr/local/bin/pandoc +RTS -K512m -RTS report_1.knit.md --to latex --from markdown+autolink_bare_uris+tex_math_single_backslash --output report_1.tex --lua-filter /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/rmarkdown/rmarkdown/lua/pagebreak.lua --lua-filter /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/rmarkdown/rmarkdown/lua/latex-div.lua --embed-resources --standalone --highlight-style tango --pdf-engine pdflatex --variable graphics --variable 'geometry:margin=1in'
#>
#> Output created: report_1.pdf
report2 <- render("report/report 2.Rmd", knit_root_dir = ".")
#> processing file: report-2.Rmd
#> output file: /private/var/folders/4v/vh7xp8553lsbl49svl48g7p00000gp/T/RtmpxOwkWK/file53421d582141/report-2.knit.md
#> /usr/local/bin/pandoc +RTS -K512m -RTS /private/var/folders/4v/vh7xp8553lsbl49svl48g7p00000gp/T/RtmpxOwkWK/file53421d582141/report-2.knit.md --to latex --from markdown+autolink_bare_uris+tex_math_single_backslash --output report-2.tex --lua-filter /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/rmarkdown/rmarkdown/lua/pagebreak.lua --lua-filter /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/rmarkdown/rmarkdown/lua/latex-div.lua --embed-resources --standalone --highlight-style tango --pdf-engine pdflatex --variable graphics --variable 'geometry:margin=1in'
#>
#> Output created: report-2.pdf
report1
#> [1] "/private/var/folders/4v/vh7xp8553lsbl49svl48g7p00000gp/T/RtmpxOwkWK/file53421d582141/report/report_1.pdf"
report2
#> [1] "/private/var/folders/4v/vh7xp8553lsbl49svl48g7p00000gp/T/RtmpxOwkWK/file53421d582141/report-2.pdf"
fs::dir_tree()
#> .
#> ├── report
#> │ ├── report 2.Rmd
#> │ ├── report_1.Rmd
#> │ └── report_1.pdf
#> └── report-2.pdf Created on 2023-06-22 with reprex v2.0.2 |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
billdenney
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Indeed you may have found a bug, but it is not in
tarchetypes
because I can reproduce it with justrmarkdown
.