【问题标题】:Converting .Rd file to plain text将 .Rd 文件转换为纯文本
【发布时间】:2014-05-27 19:39:37
【问题描述】:

我正在尝试将 R 文档文件(扩展名 .Rd)转换为纯文本。我知道 RdUtils 包含一个名为 Rdconv 的工具,但据我所知,它只能在命令行中使用。有没有办法从 R 会话中访问 Rdconv(或类似的转换工具)?

【问题讨论】:

  • 打电话给system?

标签: r plaintext rd


【解决方案1】:

试试

tools::Rd2txt("path/to/file.Rd")

【讨论】:

  • 查看?tools::Rd2txt帮助页面上的其他导出选项
【解决方案2】:

您可以随时调用系统命令,例如使用system2 函数:

input <- '~/Projekty/stringi/man/stri_length.Rd'
output <- '/tmp/out.txt'
system2('R', paste('CMD Rdconv -t txt', filename, '-o', output))
readLines(output)
## [1] "Count the Number of Characters"
## ...

确保 R 在您系统的搜索路径中。如果不是,请将上面system2() 的第一个参数替换为完整路径,例如C:\Program Files\R\3.1\bin\R.exe.

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-12
    • 2014-09-08
    • 2020-08-27
    • 2010-11-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多