Data Science Daily Dealings: R Packages Installation 3

R Packages

New versions. Doesn’t everybody love them?

Right.

Sometimes you upgrade because a package you want is only available for a new version. Which works nicely. Then, however, after getting new versions of lots of things you find the dreaded ‘not available for R version 3.x’ for an old favourite.

All is not necessarily lost, having just done the following on a newer laptop this afternoon:

Install the devtools package.

Then, for a meta-example:

devtools::install_github("hadley/devtools")

with the package you have discovered on github’s user and repo name substituted for hadley/devtools.

Now, this may not be useful if there is no github version.

However, if there is an older package on R Forge then you may be able to install via SVN checkout.

As far as operating systems go, you will need to be able to use SVN, that is, sudo apt get subversion in this case. Or Windows equivalent.

svn checkout svn://svn.r-forge.r-project.org/svnroot/returnanalytics/

If there are multiple packages you want in that repository, then pick one:

R --vanilla CMD INSTALL --build returnanalytics/pkg/PortfolioAnalytics

If there is only one package in the repo, then :-

R --vanilla CMD INSTALL --build backagainanalytics/pkg

Yet another possibility is an R package being removed from CRAN and put in the archive, for whatever reason. In that case:

url <- "https://cran.r-project.org/src/contrib/Archive/hydrosanity/hydrosanity_0.8.76.tar.gz"
packagefile <- "hydrosanity_0.8.76.tar.gz"
download.file(url = url, destfile = packagefile)

# Install the dependencies
install.packages(c("cairoDevice"))

install.packages(c("playwith", "RGtk2", "gWidgets"))

# Install package
install.packages(pkgs=pkgFile, type="source", repos=NULL)

# Delete package file
unlink(packagefile)

Richard

Data Science Daily Dealings: R Packages Installation 2

R Packages

A similar story again. Another package, R tells me it can’t install dependency rgdal. In this case, lib-gdal was missing. A whole lot of dependencies for that, too, in linux.

Also needed were libproj-dev

The solution to find the exact name of the missing library as not quite obvious? Google. Or in this case, DuckDuckGo, as the default search engine here.

Richard

Data Science Daily Dealings: R Packages Installation

R Packages

People that don’t work with computer technology at a different level can often be seen getting frustrated when things don’t work.

People that do have this happen to them as well, but at a different level, so they perhaps tend to take it in stride more and just do the usual until things work.

An example:

A package I wanted to use had two dependencies as it turned out, neither of which would install when requested. Often that means something is missing at the operating system level. In this case, for Linux Mint (Ubuntu), it was.

tkpanel wouldn’t install as tcl/tk gear missing. In this case, tk-dev needed installing.

Trying again, it then said BWidget was missing. Same story. sudo apt-get install bwidget.

Then the package and dependencies were good to go.

Just a process you do and forget it about it, so I thought I might document them as I come across them.