7

Is it possible to install a package in R forcefully ?

> install.packages("gsubfn")
Installing package(s) into ‘/home/sebastian/R/x86_64-unknown-linux-gnu-library/2.14’
(as ‘lib’ is unspecified)
--- Please select a CRAN mirror for use in this session ---
Loading Tcl/Tk interface ... done
Warning message:
In getDependencies(pkgs, dependencies, available, lib) :
  package ‘gsubfn’ is not available (for R version 2.14.2)

In this case the package requires R >= 2.15 and I only have R 2.14.2 . Wondering whether I can do a force install .

Paul Hiemstra
  • 59,984
  • 12
  • 142
  • 149
MadSeb
  • 7,958
  • 21
  • 80
  • 121
  • 8
    Download and unpack the source, change the "Depends" field in the "DESCRIPTION" file, then build/INSTALL the package... just don't come back and ask why something in the package doesn't work. – Joshua Ulrich May 03 '12 at 20:56
  • 2
    you can also visit the [archive](http://cran.r-project.org/src/contrib/Archive/gsubfn/) and potentially find some backward compatibility... but I'd mostly listen to Joshua's warning! – Justin May 03 '12 at 21:29
  • 3
    You could forcefully install 2.15 – Dason May 03 '12 at 21:39
  • 6
    @Dason I did that once a little too forcefully and broke my keyboard. – joran May 03 '12 at 21:55

1 Answers1

4

Download the package from the source. Unzip it, and move the folder to the library (~/R/2.14/Library). Go to your IDE and do a library(<package_name>)

This may or may not work properly and you are most likely to get a similar warning message saying that package <name> was built under R 2.14. Ignore it. Most of the functions should work. Be warned, however, there may be some functions which spew funny output, or none at all, as they might be using some features which are not in R 2.14.

You could, however, update your R version. That, IMO, is the best way to go.

jackStinger
  • 2,035
  • 5
  • 23
  • 36
  • Moving an unzipped version of the package source directly into the library is not the correct way to install a package. That is what `R CMD INSTALL` is for. However, as other comments have noted, the restrictions in the DESCRIPTION file would have to be changed and likely something somewhere will break. – Brian Diggs Jan 07 '13 at 21:51
  • 1
    Agree with you on that. The way I suggested is stop-gap, or, as I would put it, 'Jugaad'. Most def not the right way to go about it. However, if the OP needs only some functionalities, there is an outside chance that he gets what he needs. – jackStinger Jan 08 '13 at 05:05