Show an Rd file in viewer from Rstudio

喜欢而已 提交于 2020-02-16 03:38:44

问题


I have documentation for functions and datasets in a project folder. In a documentation folder, I have .Rd files for all the datasets. I'd like the user to be able to call a custom help function and launch the .Rd file in the viewer as is done automatically when the file is compiled from the file editor. Is it possible to do this?


回答1:


I don't quite understand why you want to do this, but it's possible. What you should do is just put your datasets into a package, document them there, and then users get easy access to them.

But if you really want to avoid that for some reason, here's how:

library(magrittr)
library(htmltools)
library(tools)
f <- "some.Rd"   # Set a filename for an Rd file here
f %>% 
  parse_Rd %>% 
  (function(x) capture.output(Rd2HTML(x))) %>% 
  HTML %>% 
  browsable


来源:https://stackoverflow.com/questions/49740952/show-an-rd-file-in-viewer-from-rstudio

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!