【问题标题】:Running R scripts from UBUNTU fails due to packages installation由于软件包安装,从 UBUNTU 运行 R 脚本失败
【发布时间】:2020-10-22 09:02:01
【问题描述】:

我正在尝试从 Ubuntu 运行 R 脚本。 R 脚本使用 vcfR 库:

install.packages("vcfR")
library("vcfR")

vcf.rout<-"/mnt/c/Users/PC/Documents/aDNA/haplotypes.vcf"
vcf<-read.vcfR(vcf.rout)

当我在 R 中运行脚本时,它运行良好, 但是当我在 Ubuntu 中运行脚本时,我得到了这个错误:

batelziv@DESKTOP-PGCKNUM:~$ Rscript /mnt/c/Users/PC/Documents/aDNA/Rs/unt1.R <br />
Installing package into ‘/usr/local/lib/R/site-library’<br />
(as ‘lib’ is unspecified)<br />
Warning in install.packages("vcfR") :<br />
'lib = "/usr/local/lib/R/site-library"' is not writable<br />
Error in install.packages("vcfR") : unable to install packages<br />
Execution halted

我还尝试在没有库相关行的情况下运行脚本:

library("vcfR")

vcf.rout<-"/mnt/c/Users/PC/Documents/aDNA/haplotypes.vcf"
vcf<-read.vcfR(vcf.rout)

我得到:

    Error in library("vcfR") : there is no package called ‘vcfR’
    Execution halted

为什么 Ubuntu 不能使用已经安装的软件包?
为什么安装时遇到问题?

【问题讨论】:

    标签: r ubuntu windows-subsystem-for-linux vcf-vcard


    【解决方案1】:

    你有一个错误

    'lib = "/usr/local/lib/R/site-library"' 不可写

    您无权将包写入此路径。 我想当你安装的时候,你可以用其他路径添加选项lib或者检查你是否不能写入它。

    install.packages(pkgs, lib = ...)

    【讨论】:

    • 通常Ubuntu系统上的路径设置为~/R/...,在我的例子中是~/R/x86_64-pc-linux-gnu-library/4.0,你可以通过在R中调用.libPaths()来检查。
    • @David .libPaths() 返回/usr/local/lib/R/site-library。因为开始安装进度消息打印Installing package into ‘/usr/local/lib/R/site-library’。所以我认为他/她不需要检查。
    • 没错,.libPaths() 打印软件包安装到的当前路径。我的意思是说检查它只是为了更好地理解内部结构,而不一定是为了获得这个特定用例的路径。也许我应该再澄清一点。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-12
    • 2018-07-08
    • 2015-01-04
    • 2018-10-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多