gpt4 book ai didi

r - 错误 : package was installed by an R version with different internals; it needs to be reinstalled

转载 作者:行者123 更新时间:2023-12-05 07:34:22 24 4
gpt4 key购买 nike

我遇到了包安装问题,我完全不知道如何处理这种情况。

install.packages("C:/Users/Oliver/Downloads/NPRED.zip", repos = NULL, type = "win.binary")
Installing package into ‘C:/Users/Oliver/Documents/R/win-library/3.5’
(as ‘lib’ is unspecified)
package ‘NPRED’ successfully unpacked and MD5 sums checked
library("NPRED", lib.loc="~/R/win-library/3.5")

*

> Error: package or namespace load failed for ‘NPRED’:
> package ‘NPRED’ was installed by an R version with different internals; it needs to be reinstalled for use with this R version

*

谁能帮我解决这个问题??

非常感谢!干杯,奥利

最佳答案

# Find the currently installed packages, put this in a data frame
df_all_packages <- as.data.frame(installed.packages())

看看这个,检查那里有哪些主要和次要的 R 版本。

View(df_all_packages)
table(df_all_packages$Built) # how many packages built under each version of R

以下示例假设您使用 R 4 并希望升级一些基于 R 3.6 的包。您应该根据自己的情况进行调整。

# Find older package versions, make a list with packages which are of older version and you want to update
df_packages_to_upgrade <- as.data.frame(subset(df_all_packages, (Built %in% c('3.6.1', '3.6.2','3.6.3'))))
# Or you can prefer to base the filtering on those you want to keep, if so uncomment next line:
# df_packages_to_upgrade <- as.data.frame(subset(df_all_packages, !(Built %in% c('4.0.1', '4.0.2','4.0.3'))))

# Finally re-install the packages :
install.packages(df_packages_to_upgrade$Package)

有时,上述会失败。特定包的依赖项可能会发生变化,这可能很难跟踪;这可能涉及棘手的操作系统级依赖关系。在一种情况下,我必须这样做:

# At bash command line, as root:
yum install jq-devel protobuf-devel libcurl-devel openssl-devel geos-devel gdal gdal-devel proj-devel proj-nad proj-epsg libjpeg-turbo*
# use 'apt-get install' on Debian-based
# Then, in R (as linux super-user), remove all old packages - but before, make a copy-paste of the list, just in case
# The list:
old_packages_removed <- rownames(df_packages_to_upgrade)

remove.packages(df_packages_to_upgrade$Package)
# Then I installed the 2 or 3 packages I really needed, which ended up installing 50 packages (most of the previously un-installed ones)
# You could try, instead:
install.packages(old_packages_removed)

这为我解决了这个问题。

关于r - 错误 : package was installed by an R version with different internals; it needs to be reinstalled,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50144957/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com