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.

Jupyter Notebooks and downloading as other formats

Jupyter Notebook

When you have finished with a Jupyter notebook, you often want to save it to another format for use elsewhere.

If this format is pdf it can be a non-trivial exercise. You might say nbconvert errors and xelatex missing path errors etc.

Basically, you need LaTex and Pandoc. For Windows MikTex and for linux, TexLive can be installed from the internet. Given that it is 4GB or thereabouts, if you are going to want to do it on more than one machine, you can download a DVD ISO.

For a linux install once successful (after possibly grumbling about install permissions) you need to add PATH, MANPATH and INFOPATH environment variables as directed.

If there are still problems you can download the tex format and use Pandoc directly, too. e.g

pandoc VenusFEMSTEM.tex -o VenusFEMSTEM.pdf

If installing jupyter notebooks for the first time you will also want the usual python suspects like numpy, scipy, etc. if not installed already. Which is much more pleasant in linux than having to go retrieve the correct .whl useful from somewhere else.

Quick example

Richard

Jupyter Notebooks and downloading as other formats

Jupyter Notebook

When you have finished with a Jupyter notebook, you often want to save it to another format for use elsewhere.

If this format is pdf it can be a non-trivial exercise. You might say nbconvert errors and xelatex missing path errors etc.

Basically, you need LaTex and Pandoc. For Windows MikTex and for linux, TexLive can be installed from the internet. Given that it is 4GB or thereabouts, if you are going to want to do it on more than one machine, you can download a DVD ISO.

For a linux install once successful (after possibly grumbling about install permissions) you need to add PATH, MANPATH and INFOPATH environment variables as directed.

If there are still problems you can download the tex format and use Pandoc directly, too. e.g

pandoc VenusFEMSTEM.tex -o VenusFEMSTEM.pdf

If installing jupyter notebooks for the first time you will also want the usual python suspects like numpy, scipy, etc. if not installed already. Which is much more pleasant in linux than having to go retrieve the correct .whl useful from somewhere else.

Quick example

Richard

GovHacked

A week ago today at this time I set off for GovHack 2017 in Adelaide.  Failed to get any red lights and turned up early.  I was the first Mentor though.    Ok, officially I was entitled Coach – Strategy and Data Science, but Mentor was the collective noun applied to everyone for the weekend, it seemed.

So I got to chat to a few people as they arrived and collected their various coloured lanyards for Volunteer, Mentor, Competitor.  Plus, pizza!

It was a great experience and I was glad I could help.  The team did a great job.  And well done to UniSA, too, for hosting.

You can browse the list of projects produced around the country at the GovHack 2017 hackerspace.

I am still working my way through those I didn’t get to observe in person.

Richard