Create a default comment header template in R?

前端 未结 3 1746
误落风尘
误落风尘 2021-02-04 10:36

Is it possible to create a default comment header template in R for all new scripts?

I generally include some standard info at the top of all my scripts and would like

3条回答
  •  离开以前
    2021-02-04 11:04

    If you are using vim you could define a snippet like this ultisnips one in a separate R-snippet file:

    snippet header "R Header template" b
    #' ---
    #' title:  ${1:title here}
    #' author: ${2:John Smith (John@Smith.com)}
    #' date:   ${3:`date +%Y-%m-%d`}
    #' ---
    endsnippet
    

    You would only have to type header which is a massive time-saver especially since it fills in predefined values (such date).

    This seems also Rmarkdown compatible as discussed here.

提交回复
热议问题