Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

calling R (2.15.3) from within R (3.0.2)

Tags:

r

I would like to be able to call R (2.15.3) from within R (3.0.2). In order to use a package (windows binary, not on cran) that is available in only the older version of R. Is this possible?

like image 688
adam.888 Avatar asked Dec 20 '22 20:12

adam.888


1 Answers

This is R. There is no if, only how

said Simon Blomberg.

You could call an older version of R using system() and the appropriate hacks in your OS. Which is something odd to do, and opens tons of possibilities for serious damage to your computer when you hit it in frustration.

Or you could download the source of the package and rebuild it in R 3.0. There's been some rather drastic internal changes in the way packages are built and used in R (the most obvious being the removal of support for packages without a namespace).

Hence :

  • if the package does not have a namespace: download the source (.tar.gz), read the manual "Writing R extensions" if you didn't before, and add a namespace file with the usual exports. As explained in Writing R extensions, this can be as simple as adding a single line

    exportPattern("^[^\\.]")
    
  • if the package has a namespace, build from source on your machine and you should be good to go. This is simply done by using:

    install.packages("path/to/package.tar.gz",type="source")
    

Note that if you want to install from source on a Windows machine, you'll need a compatible version of Rtools : http://cran.r-project.org/bin/windows/Rtools/

If you don't want to be bothered with it, mail the author/maintainer of the package and kindly ask if they'd like to rebuild it for you.

like image 90
Joris Meys Avatar answered Dec 22 '22 11:12

Joris Meys