在 Rstudio 的查看器中显示 Rd 文件 [英] Show an Rd file in viewer from Rstudio

查看:90
本文介绍了在 Rstudio 的查看器中显示 Rd 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在项目文件夹中有函数和数据集的文档.在文档文件夹中,我有所有数据集的 .Rd 文件.我希望用户能够调用自定义帮助功能并在查看器中启动 .Rd 文件,就像从文件编辑器编译文件时自动完成的那样.可以这样做吗?

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?

推荐答案

我不太明白你为什么要这样做,但这是可能的.您应该做的只是将您的数据集放入一个包中,在那里记录它们,然后用户可以轻松访问它们.

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

这篇关于在 Rstudio 的查看器中显示 Rd 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆