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
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?
If you have to install old versions of packages, you can download them from the package archives. For the forecast package, go to cran.r-project.org/src/contrib/Archive/forecast/. However, that is only going to help non-Windows users. For Windows, you need the binary zip file instead.
1 Answer. You can use the packageVersion() function to print version information about the loaded packages. To print the version information about R, the OS and attached or loaded packages, use the sessionInfo() function.
How to Update R. The easiest way to update R is to simply download the newest version. Install that, and it will overwrite your current version. There are also packages to do the updating: updateR for Mac, and installr for Windows.
In the R terminal, type R. version . It's R. version .
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
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)
Update: Testing on 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):
> 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.
You can use the METACRAN mirror:
Go to the blame page of the DESCRIPTION
file of the package you're interested in.
E.g. for tm
: https://github.com/cran/tm/blame/master/DESCRIPTION
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.
If you want to automate that, it may be better to use crandb (also from 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With