如何确定哪个旧版本的R包与我的R版本兼容

时间:2021-08-02 13:41:15

I am trying to install the "tm" package but then I get an error saying that "tm" is not available for my R version

我正在尝试安装“tm”软件包,但后来我收到一条错误消息,说我的R版本“tm”不可用

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

and then try installing from source.

然后尝试从源代码安装。

My question is how do I determine which file there in the list is compatible with my R version?

我的问题是如何确定列表中的哪个文件与我的R版本兼容?

4 个解决方案

#1


7  

You can use the METACRAN mirror:

您可以使用METACRAN镜像:

Go to the blame page of the DESCRIPTION file of the package you're interested in.

转到您感兴趣的软件包的DESCRIPTION文件的blame页面。

E.g. for tm: https://github.com/cran/tm/blame/master/DESCRIPTION

例如。 for tm:https://github.com/cran/tm/blame/master/DESCRIPTION

如何确定哪个旧版本的R包与我的R版本兼容

Find the Depends line and click as many times as needed on the View blame prior to this change icon, until an old enough R version is displayed.

找到Depends行并在此更改图标之前根据需要在View blame上单击多次,直到显示足够旧的R版本。

If you want to automate that, it may be better to use crandb (also from METACRAN).

如果你想自动化,最好使用crandb(也来自METACRAN)。

Side note: sometimes package authors list R (≥ x.y.z) as a dependency just to be safe because they use version x.y.z and didn't do any tests with previous versions.

旁注:有时包装作者列出R(≥x.y.z)作为依赖只是为了安全,因为他们使用版本x.y.z并且没有使用以前的版本进行任何测试。

#2


6  

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:

我在这里开发了一个与这个方法相关的答案,但它只使用了基础R(你不需要XML或devtools或任何东西)。它还可能处理一些可能无法通过我从另一个问题链接到的解决方案来解决的突发事件。因为它是大约100行代码,而不是在这里发布一个巨大的函数,所以我把它放到了一个可以从GitHub获得的包中:

oldr package GitHub repo

oldr包GitHub repo

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:

该软件包只有一个导出函数install.compatible.packages()。我在Ubuntu 18.04上测试过它。我安装了R 3.1.0并安装了tm(及其依赖项)。当前版本的tm需要R 3.2.0,因此无法通过install.packages()获得,但我的函数允许其安装:

> 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)

Update: Testing on Windows

更新:在Windows上进行测试

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):

我现在也有机会在Windows(8.1)上进行测试,并且一切顺利地将tm安装到旧版本的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:\Users\User\AppData\Local\Temp\RtmpojDNlF\downloaded_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:\Users\User\AppData\Local\Temp\RtmpojDNlF\downloaded_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:\Users\User\AppData\Local\Temp\RtmpojDNlF\downloaded_packages

Update: Additional Parameters

更新:附加参数

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_version参数),以及将软件包安装到(lib参数)的目录,这可能对测试或其他用途有用。

#3


2  

You can download the archived package and then untar and un-gzip it. The DESCRIPTION file lists the version of R that it needs. In your case the file tm_0.5-10.tar.gz (that is, the most recent archive version, but not the current version) has this line:

您可以下载存档的包,然后解压缩并解压缩它。 DESCRIPTION文件列出了它所需的R版本。在您的情况下,文件tm_0.5-10.tar.gz(即最新的存档版本,但不是当前版本)具有以下行:

Depends: R (>= 3.0.0)

Version 0.6 of the tm package updated its dependency to R greater than or equal to 3.1.0.

tm软件包的0.6版将其依赖关系更新为R大于或等于3.1.0。

#4


2  

Another option would be to upgrade your version of R so it is compatible with that latest version of the "tm" package. You can do that easily within R by using the following code:

另一种选择是升级您的R版本,使其与最新版本的“tm”软件包兼容。您可以使用以下代码在R中轻松完成此操作:

# install the latest installr package: 
install.packages("installr")

# require the latest installr package: 
require(installr)

#run the command to update R
updateR()

HT: http://www.r-statistics.com/2014/07/r-3-1-1-is-released-and-how-to-quickly-update-it-on-windows-os/

HT:http://www.r-statistics.com/2014/07/r-3-1-1-is-released-and-how-to-quickly-update-it-on-windows-os/

#1


7  

You can use the METACRAN mirror:

您可以使用METACRAN镜像:

Go to the blame page of the DESCRIPTION file of the package you're interested in.

转到您感兴趣的软件包的DESCRIPTION文件的blame页面。

E.g. for tm: https://github.com/cran/tm/blame/master/DESCRIPTION

例如。 for tm:https://github.com/cran/tm/blame/master/DESCRIPTION

如何确定哪个旧版本的R包与我的R版本兼容

Find the Depends line and click as many times as needed on the View blame prior to this change icon, until an old enough R version is displayed.

找到Depends行并在此更改图标之前根据需要在View blame上单击多次,直到显示足够旧的R版本。

If you want to automate that, it may be better to use crandb (also from METACRAN).

如果你想自动化,最好使用crandb(也来自METACRAN)。

Side note: sometimes package authors list R (≥ x.y.z) as a dependency just to be safe because they use version x.y.z and didn't do any tests with previous versions.

旁注:有时包装作者列出R(≥x.y.z)作为依赖只是为了安全,因为他们使用版本x.y.z并且没有使用以前的版本进行任何测试。

#2


6  

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:

我在这里开发了一个与这个方法相关的答案,但它只使用了基础R(你不需要XML或devtools或任何东西)。它还可能处理一些可能无法通过我从另一个问题链接到的解决方案来解决的突发事件。因为它是大约100行代码,而不是在这里发布一个巨大的函数,所以我把它放到了一个可以从GitHub获得的包中:

oldr package GitHub repo

oldr包GitHub repo

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:

该软件包只有一个导出函数install.compatible.packages()。我在Ubuntu 18.04上测试过它。我安装了R 3.1.0并安装了tm(及其依赖项)。当前版本的tm需要R 3.2.0,因此无法通过install.packages()获得,但我的函数允许其安装:

> 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)

Update: Testing on Windows

更新:在Windows上进行测试

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):

我现在也有机会在Windows(8.1)上进行测试,并且一切顺利地将tm安装到旧版本的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:\Users\User\AppData\Local\Temp\RtmpojDNlF\downloaded_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:\Users\User\AppData\Local\Temp\RtmpojDNlF\downloaded_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:\Users\User\AppData\Local\Temp\RtmpojDNlF\downloaded_packages

Update: Additional Parameters

更新:附加参数

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_version参数),以及将软件包安装到(lib参数)的目录,这可能对测试或其他用途有用。

#3


2  

You can download the archived package and then untar and un-gzip it. The DESCRIPTION file lists the version of R that it needs. In your case the file tm_0.5-10.tar.gz (that is, the most recent archive version, but not the current version) has this line:

您可以下载存档的包,然后解压缩并解压缩它。 DESCRIPTION文件列出了它所需的R版本。在您的情况下,文件tm_0.5-10.tar.gz(即最新的存档版本,但不是当前版本)具有以下行:

Depends: R (>= 3.0.0)

Version 0.6 of the tm package updated its dependency to R greater than or equal to 3.1.0.

tm软件包的0.6版将其依赖关系更新为R大于或等于3.1.0。

#4


2  

Another option would be to upgrade your version of R so it is compatible with that latest version of the "tm" package. You can do that easily within R by using the following code:

另一种选择是升级您的R版本,使其与最新版本的“tm”软件包兼容。您可以使用以下代码在R中轻松完成此操作:

# install the latest installr package: 
install.packages("installr")

# require the latest installr package: 
require(installr)

#run the command to update R
updateR()

HT: http://www.r-statistics.com/2014/07/r-3-1-1-is-released-and-how-to-quickly-update-it-on-windows-os/

HT:http://www.r-statistics.com/2014/07/r-3-1-1-is-released-and-how-to-quickly-update-it-on-windows-os/