rstudio / rticles

LaTeX Journal Article Templates for R Markdown
https://pkgs.rstudio.com/rticles/
1.47k stars 519 forks source link

R file produced by `rjournal_article` is not replaced by new one #394

Closed cderv closed 3 years ago

cderv commented 3 years ago

We forgot to set overwrite = FALSE here I think: https://github.com/rstudio/rticles/blob/84a8fb4d705990cf455ff8cb1e0c8340d04bda0a/R/rjournal_article.R#L94

Meaning that the new purled R file was not copied to the output dir unless the previous one was cleaned. No error or warning issued with file.copy in this case...

That is nasty bug I think. But with an easy fix

Thanks @apreshill for finding this

Enchufa2 commented 3 years ago

I suppose this is a feature to automatically generate the replication script from the Rmd. But I always maintain a separate filename.R replication script, and now it gets overwritten after this change. Is there an option to switch off this feature?

Enchufa2 commented 3 years ago

I see no way to switch this off. And given that previously it was possible to maintain a custom replication script, I consider this a regression. A proper fix would be to add some comment to the generated file (like "this was automatically generated, do not edit by hand"), and only overwrite it if such comment is present. In this way, previous behavior would be preserved, as well as the originally intended feature.

cderv commented 3 years ago

Hi @Enchufa2 !

Thanks for the report. This is indeed something we did not think through. The feature is to automatically generate the R script from the content of the Rmd file (using knitr::purl()), however we assume the R file is indeed only produced by rticles. We need to provide a way to opt-out for manual workflown like yours.

We could also provide an argument in the function to opt-out this:

output: 
  rjournal_article: 
    purl: false

I like your suggestion though with the special comment in the script.

I'll open an issue to track your report specifically.

Enchufa2 commented 3 years ago

Nice, thanks!

github-actions[bot] commented 2 years ago

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.