简体   繁体   English

在Rstudio的查看器中显示Rd文件

[英]Show an Rd file in viewer from Rstudio

I have documentation for functions and datasets in a project folder. 我在项目文件夹中有函数和数据集的文档。 In a documentation folder, I have .Rd files for all the datasets. 在一个文档文件夹中,我具有所有数据集的.Rd文件。 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. 我希望用户能够调用自定义帮助功能并在查看器中启动.Rd文件,就像从文件编辑器编译文件时自动完成的那样。 Is it possible to do this? 是否有可能做到这一点?

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM