Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add date to rmarkdown file output name when clicking "knit" #1153

Closed
jarbet opened this issue Jul 19, 2022 · 2 comments
Closed

Add date to rmarkdown file output name when clicking "knit" #1153

jarbet opened this issue Jul 19, 2022 · 2 comments
Labels

Comments

@jarbet
Copy link

jarbet commented Jul 19, 2022

Describe the bug
I am using rmarkdown within VSCode, and would like to automatically add today's date to the output filename when clicking the 'knit' button. I see that this feature was requested here and added in PR #765, however, I can't get it to work.

To Reproduce
Steps to reproduce the behavior:

  1. Create file test.Rmd that contains the following code:
---
title: "hello world"
knit: (function(input, ...) {
    rmarkdown::render(
      input,
      output_file = paste0(
        xfun::sans_ext(input), '-', Sys.Date(), '.html'
      ),
      envir = globalenv()
    )
  })
---

hello world
  1. Click on Knit > Rmd button:
    image

  2. Unfortunately, the output filename is test.html and does not contain the date:
    image

Note after clicking the knit button, the following command is automatically called (which I suspect is causing the date to be removed from the filename):

rmarkdown::render("test.Rmd", encoding = "UTF-8")

Environment (please complete the following information):

  • OS: macOS but I am using VSCode to connect to a remote server where I am using Rmarkdown/R for analysis
  • VSCode Version: 1.69.1
  • R Version: 4.1.3
  • vscode-R version: v\2.5.2
@jarbet jarbet added the bug label Jul 19, 2022
@ElianHugh
Copy link
Collaborator

I can't replicate this locally -- I'd just like to double check that you have enabled the VSC setting rmarkdown.knit.useBackgroundProcess as otherwise vscode-R will default to standard knitting in the interactive terminal

@jarbet
Copy link
Author

jarbet commented Jul 20, 2022

I can't replicate this locally -- I'd just like to double check that you have enabled the VSC setting rmarkdown.knit.useBackgroundProcess as otherwise vscode-R will default to standard knitting in the interactive terminal

It works now after checking that box. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants