代码之家  ›  专栏  ›  技术社区  ›  matsuo_basho

重建自定义R包时,依赖项下列出的包未安装

  •  0
  • matsuo_basho  · 技术社区  · 6 年前

    我正在重建一个定制的R包,其中在描述文件的dependens行中有RcppArmadillo。

    我正在运行r3.5.1。在RStudio中重建包时,出现错误:

    ERROR: dependency ‘RcppArmadillo’ is not available for package 'custom package name'
    

    根据 R Packages book ,重新生成包时必须安装依赖/导入下的包。

    1 回复  |  直到 6 年前
        1
  •  1
  •   duckmayr    6 年前

    解决方案

    使用 devtools::install() 相反。

    解释

    根据 RStudio website ,

    Build and Reload命令按顺序执行几个步骤,以确保得到干净、正确的结果:
    1.卸载包的任何现有版本(必要时包括共享库)。
    2.使用R CMD INSTALL构建和安装包。
    3.重新启动底层R会话,以确保重新加载包的环境干净。
    4.通过执行库函数在新的R会话中重新加载包。

    devtools::install() 将为您安装依赖项--从 help("install.packages") :

    使用R CMD INSTALL安装包。威尔 尝试安装 来自CRAN的包的依赖项,如果它们还没有 安装。

    (强调补充)这不是 R CMD INSTALL 独自一人(见 ?INSTALL 从R或 R CMD INSTALL --help

    所以,它似乎是一种语言

    尚未存在,请安装到您的计算机上

    从哈德利那里 R Packages 有点具体;它不适用于使用 R命令安装 (RStudio的build函数显然使用了这个函数),但确实适用于 . 这是个人品味的问题,但老实说,我强烈建议使用 devtools 在包开发工作流中。

    例子

    rbenchmark 从我的系统通过

    remove.packages("rbenchmark")
    

    然后创建一个虚拟包

    devtools::create("SOexample", rstudio = FALSE)
    

    本奇马克 在进口中 SOexample 看情况而定。我在中添加了以下代码 R/hello_world.R :

    hello_world <- function() print("Hello, world!")
    

    R命令安装 ,但出现了错误

    *安装到library/home/duckmayr/R/x86_64-pc-linux-gnu-library/3.5

    *删除/home/duckmayr/R/x86_64-pc-linux-gnu-library/3.5/soe示例

    devtools::install() :

    > devtools::install("SOexample/")
    Installing SOexample
    trying URL 'https://cloud.r-project.org/src/contrib/rbenchmark_1.0.0.tar.gz'
    Content type 'application/x-gzip' length 5093 bytes
    ==================================================
    downloaded 5093 bytes
    
    Installing rbenchmark
    '/usr/lib/R/bin/R' --no-site-file --no-environ --no-save --no-restore --quiet  \
      CMD INSTALL '/tmp/RtmpA0NOMe/devtools723832018149/rbenchmark'  \
      --library='/home/duckmayr/R/x86_64-pc-linux-gnu-library/3.5' --install-tests 
    
    * installing *source* package ‘rbenchmark’ ...
    ** package ‘rbenchmark’ successfully unpacked and MD5 sums checked
    ** R
    ** demo
    ** byte-compile and prepare package for lazy loading
    ** help
    *** installing help indices
    ** building package indices
    ** testing if installed package can be loaded
    * DONE (rbenchmark)
    '/usr/lib/R/bin/R' --no-site-file --no-environ --no-save --no-restore --quiet  \
      CMD INSTALL '/home/duckmayr/SOexample'  \
      --library='/home/duckmayr/R/x86_64-pc-linux-gnu-library/3.5' --install-tests 
    
    * installing *source* package ‘SOexample’ ...
    ** R
    ** byte-compile and prepare package for lazy loading
    ** help
    No man pages found in package  ‘SOexample’ 
    *** installing help indices
    ** building package indices
    ** testing if installed package can be loaded
    * DONE (SOexample)
    
    推荐文章