如何确定哪个旧版本的 R 包与我的 R 版本兼容 [英] How to determine which older version of the R package is compatible with my R version
问题描述
我正在尝试安装tm"包,但随后我收到一条错误消息,提示tm"不适用于我的 R 版本
I am trying to install the "tm" package but then I get an error saying that "tm" is not available for my R version
package ‘tm’ is not available (for R version 3.0.2)
但后来我看到有人建议我从
But then I saw that someone suggested I download the archived version from
http://cran.r-project.org/src/contrib/Archive/tm/?C=M;O=A
然后尝试从源安装.
我的问题是如何确定列表中的哪个文件与我的 R 版本兼容?
My question is how do I determine which file there in the list is compatible with my R version?
推荐答案
我开发了一个与方法相关的答案这里,但仅使用基本 R(您不需要 XML
或 devtools
或任何东西).它还可能处理一些我从另一个问题链接到的解决方案可能无法解决的突发事件.由于它大约有 100 行代码,而不仅仅是在这里发布一个巨大的函数,我将它整合到一个包 oldr
你可以从 GitHub 获得:
I developed an answer related to the approach here, but which uses only base R (you don't need XML
or devtools
or anything). It also potentially handles some contingencies that may not be addressed by the solution I linked to from the other question. Since it was around 100 lines of code, rather than just post a huge function here, I rolled it into a package oldr
you can get from GitHub here:
oldr
package GitHub repo
这个包只有一个导出函数,install.compatible.packages()
.我已经在 Ubuntu 18.04 上对其进行了测试.我安装了 R 3.1.0 并安装了 tm
(及其依赖项).当前版本的 tm
需要 R 3.2.0,因此无法通过 install.packages()
获得,但我的函数允许安装它:
The package has just one exported function, install.compatible.packages()
. I have tested it on Ubuntu 18.04. I installed R 3.1.0 and installed tm
(and its dependencies). The current version of tm
requires R 3.2.0, so wouldn't be available via install.packages()
, but my function allows its installation:
> oldr::install.compatible.packages("NLP")
Installing package into ‘/home/duckmayr/R/x86_64-unknown-linux-gnu-library/3.1’
(as ‘lib’ is unspecified)
* installing *source* package ‘NLP’ ...
** package ‘NLP’ successfully unpacked and MD5 sums checked
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (NLP)
> oldr::install.compatible.packages("slam")
Installing package into ‘/home/duckmayr/R/x86_64-unknown-linux-gnu-library/3.1’
(as ‘lib’ is unspecified)
* installing *source* package ‘slam’ ...
** package ‘slam’ successfully unpacked and MD5 sums checked
** libs
gcc -I/opt/R/3.1.0/lib/R/include -DNDEBUG -I/usr/local/include -fpic -g -O2 -c apply.c -o apply.o
gcc -I/opt/R/3.1.0/lib/R/include -DNDEBUG -I/usr/local/include -fpic -g -O2 -c grouped.c -o grouped.o
gcc -I/opt/R/3.1.0/lib/R/include -DNDEBUG -I/usr/local/include -fpic -g -O2 -c sparse.c -o sparse.o
gcc -I/opt/R/3.1.0/lib/R/include -DNDEBUG -I/usr/local/include -fpic -g -O2 -c util.c -o util.o
gcc -shared -L/usr/local/lib -o slam.so apply.o grouped.o sparse.o util.o -L/opt/R/3.1.0/lib/R/lib -lRblas -lgfortran -lm -lquadmath -L/opt/R/3.1.0/lib/R/lib -lR
installing to /home/duckmayr/R/x86_64-unknown-linux-gnu-library/3.1/slam/libs
** R
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (slam)
> oldr::install.compatible.packages("tm")
Installing package into ‘/home/duckmayr/R/x86_64-unknown-linux-gnu-library/3.1’
(as ‘lib’ is unspecified)
* installing *source* package ‘tm’ ...
** package ‘tm’ successfully unpacked and MD5 sums checked
** libs
gcc -I/opt/R/3.1.0/lib/R/include -DNDEBUG -I/usr/local/include -fpic -g -O2 -c copy.c -o copy.o
gcc -shared -L/usr/local/lib -o tm.so copy.o -L/opt/R/3.1.0/lib/R/lib -lR
installing to /home/duckmayr/R/x86_64-unknown-linux-gnu-library/3.1/tm/libs
** R
** data
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
* DONE (tm)
更新:在 Windows 上测试
我现在也有机会在 Windows (8.1) 上进行测试,并且将 tm
安装到旧版本的 R (v. 3.1.0) 上一切正常:
I now have also had the chance to test on Windows (8.1), and everything worked smoothly for installing tm
to an old version of R (v. 3.1.0):
> oldr::install.compatible.packages("NLP")
Installing package into ‘C:/Users/User/Documents/R/win-library/3.1’
(as ‘lib’ is unspecified)
trying URL 'http://mirror.las.iastate.edu/CRAN/bin/windows/contrib/3.1/NLP_0.1-9.zip'
Content type 'application/zip' length 278699 bytes (272 Kb)
opened URL
downloaded 272 Kb
package ‘NLP’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:UsersUserAppDataLocalTempRtmpojDNlFdownloaded_packages
> oldr::install.compatible.packages("slam")
Installing package into ‘C:/Users/User/Documents/R/win-library/3.1’
(as ‘lib’ is unspecified)
trying URL 'http://mirror.las.iastate.edu/CRAN/bin/windows/contrib/3.1/slam_0.1-32.zip'
Content type 'application/zip' length 111528 bytes (108 Kb)
opened URL
downloaded 108 Kb
package ‘slam’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:UsersUserAppDataLocalTempRtmpojDNlFdownloaded_packages
> oldr::install.compatible.packages("tm")
Installing package into ‘C:/Users/User/Documents/R/win-library/3.1’
(as ‘lib’ is unspecified)
trying URL 'http://mirror.las.iastate.edu/CRAN/bin/windows/contrib/3.1/tm_0.6-2.zip'
Content type 'application/zip' length 710798 bytes (694 Kb)
opened URL
downloaded 694 Kb
package ‘tm’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:UsersUserAppDataLocalTempRtmpojDNlFdownloaded_packages
更新:附加参数
现在用户可以指定尝试安装哪个版本的 R(R_version
参数),以及将包安装到哪个目录(lib
参数),这可能很有用用于测试或其他目的.
Now users can specify which version of R to attempt installation for (R_version
parameter), and which directory to install packages to (lib
parameter), which could be useful for testing or other purposes.
这篇关于如何确定哪个旧版本的 R 包与我的 R 版本兼容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!