How to knit pdf from rmd script by clicking an executable r file?

前端 未结 1 901
Happy的楠姐
Happy的楠姐 2020-12-31 18:27

Synopsis

I would like to produce a pdf file from an rmd script just by clicking a file / an icon so that my coworkers don\'t exhaust themselves by o

1条回答
  •  囚心锁ツ
    2020-12-31 19:17

    Assuming one has independently installed pandoc on Windows machine (which turned out to be the root of the problem in this case), she can do it in the following manner:

    First: make a .R file with the content like below

    library(knitr)
    library(rmarkdown)
    setwd('C:/repos/r_tutorials/executable R files')
    knit("RexecKnit.Rmd")
    
    # render the generated markdown file.
    render("RexecKnit.md")
    
    Sys.sleep(3)
    

    Second: make a .bat file

    Create a .bat file, say "my_bat_file.bat", and include the text below. However, the paths have to be adjusted:

    "C:\R\R-3.2.2\bin\x64\R.exe" CMD BATCH --vanilla --slave "C:\path_to_your_file\your_file.R" "C:\path_to_your_file\your_file.Rout"
    

    Third: Instruct Windows Task Scheduler

    If the data is updated frequently, one can shedule the Task Scheduler in Windows to repeatedly execute the .bat file once a week at certain time at night, so reports are there in the morning.

    0 讨论(0)
提交回复
热议问题