If you render the following chunk, this_file should show the name of *.Rmd file. No surprise here.
knitr::knitr_current_input()
this_file <- knitr::current_input()
this_file
If you run, not render, the 2 lines of R code in the chunk then all bets are off. I get NULL for this_file. (Be sure to remove this_file from environment 1st).
And to render, I need to supply the file name.
rmarkdown::render(input= <file_name>)
So this may be very silly question, but I want the code to figure out the name of file.
Note: I use nvim-R, not Rstudio and can use vim to insert the file name, but want to see a direct way.
Thx