无法在 Mac 上的 RStudio 中加载 BiodiversityR

问题描述 投票:0回答:1

我安装了Biodiversity,然后运行

library(BiodiversityR)
,然后它说“正在加载所需的包:tcltk”。装载持续了10个小时。然后我重新启动 mac 并再次尝试,但又发生了。

r macos rstudio
1个回答
0
投票

太长;没读过

问题通常与您的 R 版本或软件包版本有关,因此请先更新您的 R。如果不起作用,请更新您的软件包。如果 install.packages() 没有为您提供最新版本,请转到 cran 站点并下载该文件,解压缩它,然后替换库中的旧包文件。

我做了什么

我再次下载并安装了XQuartz

library(BiodiversityR)
,这次它给了我一些消息(太棒了!)如下。

# Loading required package: tcltk
# Loading required package: vegan
# Loading required package: permute
# Loading required package: lattice
# This is vegan 2.6-4
# Error: package or namespace load failed for ‘BiodiversityR’ in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]):
#   namespace ‘Rcmdr’ 2.7-2 is being loaded, but >= 2.9.1 is required
# In addition: Warning message:
#   package ‘BiodiversityR’ was built under R version 4.3.1 

错误与“Rcmdr”有关,似乎已经过时了,所以我做了

install.packages("Rcmdr”)
,但有一些警告如下。

# Installing package into ‘/Users/Kang/Library/R/x86_64/4.1/library’
# (as ‘lib’ is unspecified)
# Warning in install.packages :
#   lzma decoder corrupt data
# 
# There is a binary version available but the source version is later:
#   binary source needs_compilation
# Rcmdr  2.8-0  2.9-1             FALSE
# 
# installing the source package ‘Rcmdr’
# 
# trying URL 'https://cran.rstudio.com/src/contrib/Rcmdr_2.9-1.tar.gz'
# Content type 'application/x-gzip' length 9407419 bytes (9.0 MB)
# ==================================================
#   downloaded 9.0 MB
# 
# ERROR: failed to lock directory ‘/Users/Kang/Library/R/x86_64/4.1/library’ for modifying
# Try removing ‘/Users/Kang/Library/R/x86_64/4.1/library/00LOCK-Rcmdr’
# Warning in install.packages :
#   installation of package ‘Rcmdr’ had non-zero exit status
# 
# The downloaded source packages are in
# ‘/private/var/folders/7p/vbfp82515bbdqt0khfk6ks9w0000gn/T/RtmpDofZ5K/downloaded_packages’

看起来已经安装了Rcmdr,但是版本不是最新的。如果我们在尝试加载 BiodiversityR 后返回到最后一条错误消息,它会显示“正在加载命名空间‘Rcmdr’2.7-2,但需要 >= 2.9.1”。为了确认这一点,我检查了软件包的版本。

packageVersion("Rcmdr")
# ‘2.7.2’

所以我猜测需要更新版本的 Rcmdr。然后我尝试从 Github 安装该软件包,但没有成功。

devtools::install_github("https://github.com/cran/Rcmdr")

我访问了包的 cran 站点并下载了“Rcmdr_2.9-1.tgz”文件并将其解压缩,然后将其移至我的 R 包的文件夹中。

如果您不知道该文件夹的目录,请在 RStudio 中运行

.Library
。我检查了Rcmdr的版本,终于可以用了!

packageVersion("Rcmdr")
‘2.9.1’

现在我再次

library(BiodiversityR)
并收到以下消息。

# Loading required package: tcltk
# Loading required package: vegan
# Loading required package: permute
# Loading required package: lattice
# This is vegan 2.6-4
# BiodiversityR 2.15-4: Use command BiodiversityRGUI() to launch the Graphical User Interface; 
# to see changes use BiodiversityRGUI(changeLog=TRUE, backward.compatibility.messages=TRUE)
# 
# Warning message:
#   package ‘BiodiversityR’ was built under R version 4.3.1 

有一条警告消息,但似乎有效!至少,它可以在我的 Mac 上运行,尽管我的 R 版本低于 4.3.1。

为了防止再次发生一些意外错误,我决定更新我的 R。我访问 R 的站点并下载了最新版本并安装了它,重新启动了 RStudio。然而,在我再次尝试library(BiodiversityR)

之前,有一条消息。现在,有一个有趣的故事......它问我是否要安装一些必需的软件包,例如“BiodiversiryR”和“ggplot2”。我这两天都在做什么?!不管怎样,我说是的,它安装或更新了很多软件包。再说一遍,我
library(BiodiversityR)
。弹出一个老式窗口,询问我是否要安装 Rcmdr 所需的一些软件包。我点击“是”。顺便说一句,在这一步中,我还收到了以下消息。

Loading required package: tcltk Loading required package: vegan Loading required package: permute Loading required package: lattice This is vegan 2.6-4 also installing the dependencies ‘coda’, ‘arm’, ‘mi’, ‘mvtnorm’, ‘TH.data’, ‘commonmark’
安装完成后,又来了,

library(BiodiversityR)

。
没有任何消息。没有错误,没有警告。
有效。
再说一遍,我这两天都在做什么……

© www.soinside.com 2019 - 2024. All rights reserved.