【问题标题】:Terminal commands to install R packages with Rcpp like in Rstudio?使用 Rstudio 中的 Rcpp 安装 R 包的终端命令?
【发布时间】:2019-08-25 08:42:17
【问题描述】:

我最近在使用 R 代码时从 Rstudio 迁移到 vim。当我在 Rstudio 中单击 Install and Restart 时,我无法理解如何复制发送的命令。

据我了解,我需要运行

Rscript -e "Rcpp::compileAttributes()"
Rscript -e "devtools::document()"

复制 Rstudio 的 Document 按钮。那么

Rscript -e "Rcpp::compileAttributes()"
R CMD INSTALL --no-multiarch --with-keep.source .

应该复制Install and Restart按钮。

问题是:使用 Rstudio 的按钮可以很好地安装软件包,而运行命令则不会。尝试document() 时出现以下错误:

Updating mypkg documentation
Writing NAMESPACE
Loading mypkg
Error in representation(N = "numeric", N_dep = "numeric", vertices = "list",  : could not find function "representation"
Calls: <Anonymous> ... source_many -> source_one -> eval -> eval -> setClass -> is
Execution halted

如果我忽略它并安装包,包中唯一可用的对象是my_kpg::'.__t__[[:base'。如何构建与 Rstudio 的 DocumentInstall and Restart 按钮行为相同的命令行输入序列?

【问题讨论】:

    标签: r package rstudio


    【解决方案1】:

    事实证明 Rscript 默认情况下不会加载 methods 包,而交互式 R 会话会加载(奇怪)。问题是由于缺少包引起的。

    library(methods) 添加到我的.Rprofile 文件解决了这个问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-23
      • 2015-01-27
      • 1970-01-01
      • 2020-03-08
      • 1970-01-01
      相关资源
      最近更新 更多