请问有什么提示说明为什么我无法安装任何 R 软件包?我最近安装了 Ubuntu 20.04 LTS OS 以及 R 和 R studio。但是我无法在 R 中安装任何软件包。我读过一篇看似相关的帖子,例如无法在 Ubuntu 18.04 上安装任何 R 软件包但这些解决方案似乎对我的情况没有帮助。例如,在尝试安装 ggplot2 包时,我收到报告称各种依赖项未安装,但尝试安装其中任何一个都不起作用。我将不胜感激任何建议。
我在这里添加了尝试安装 ggplot2 包后出现的最后一个错误语句和 R 会话信息,以及运行命令R --version
和 apt-cache 策略时的输出r-base-dev
:
install.packages("ggplot2")
* removing ‘/home/power/R/x86_64-pc-linux-gnu-library/4.1/tibble’
Warning in install.packages :
installation of package ‘tibble’ had non-zero exit status
ERROR: dependencies ‘digest’, ‘glue’, ‘isoband’, ‘rlang’, ‘scales’, ‘tibble’ are not available for package ‘ggplot2’
* removing ‘/home/power/R/x86_64-pc-linux-gnu-library/4.1/ggplot2’
Warning in install.packages :
installation of package ‘ggplot2’ had non-zero exit status
> sessionInfo()
R version 4.1.0 (2021-05-18)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.2 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=de_DE.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=de_DE.UTF-8 LC_MESSAGES=en_US.UTF-8 LC_PAPER=de_DE.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=de_DE.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_4.1.0 tools_4.1.0
(base) power@power-SYS-7039A-I:~$ R --version
R version 4.1.0 (2021-05-18) -- "Camp Pontanezen"
Copyright (C) 2021 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under the terms of the
GNU General Public License versions 2 or 3.
For more information about these matters see
https://www.gnu.org/licenses/.
(base) power@power-SYS-7039A-I:~$ apt-cache policy r-base-dev
r-base-dev:
Installed: 4.1.0-1.2004.0
Candidate: 4.1.0-1.2004.0
Version table:
*** 4.1.0-1.2004.0 500
500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ Packages
100 /var/lib/dpkg/status
4.0.5-1.2004.0 500
500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ Packages
4.0.4-1.2004.0 500
500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ Packages
4.0.3-1.2004.0 500
500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ Packages
4.0.2-1.2004.0 500
500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ Packages
4.0.1-1.2004.0 500
500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ Packages
4.0.0-1.2004.0 500
500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ Packages
3.6.3-2 500
500 http://de.archive.ubuntu.com/ubuntu focal/universe amd64 Packages
500 http://de.archive.ubuntu.com/ubuntu focal/universe i386 Packages
(base) power@power-SYS-7039A-I:~$
答案1
当 R 为您编译包时,您必须仔细检查 R 控制台输出。
在新的 20.04 LTS 上R4.1,以下操作将导致成功:
sudo apt-get install r-base-dev build-essential
sudo apt-get install build-essential libssl-dev libcurl4-openssl-dev libxml2-dev libcairo2-dev libgit2-dev
mkdir -p /home/$USER/R/x86_64-pc-linux-gnu-library/4.1
R -e "install.packages(c('rlang','ggplot2'), repos='http://cran.rstudio.com/', lib='/home/$USER/R/x86_64-pc-linux-gnu-library/4.1')"