How to write contents of help to a file from within R?

前端 未结 2 1723
再見小時候
再見小時候 2020-12-04 01:13

I\'d like to be able to write the contents of a help file in R to a file from within R. The following works from the command-line:

  • R --slave -e \'library
2条回答
  •  囚心锁ツ
    2020-12-04 02:13

    Looks like the two functions you would need are tools:::Rd2txt and utils:::.getHelpFile. This prints the help file to the console, but you may need to fiddle with the arguments to get it to write to a file in the way you want.

    For example:

    hs <- help(survey)
    tools:::Rd2txt(utils:::.getHelpFile(as.character(hs)))
    

    Since these functions aren't currently exported, I would not recommend you rely on them for any production code. It would be better to use them as a guide to create your own stable implementation.

提交回复
热议问题