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

Buoys will be buoys

An idea for modelling a social field

by Cathy

Be aware that I’m a newbie in the field of sociology and my ideas are more about setting up a software framework to support modelling and simulation of complex sociological phenomena using a system of systems approach.

I understand that each of us is affected by the direct social interactions we have with the people around us and also by the general social climate (or field).  At first I was imagining modelling the social field in a similar way to the different aspects of an individual’s behaviour or the different factors affecting individuals. I was locked in a socio-dynamics modelling frame of mind, I think. Over the past few months, I’ve been thinking about modelling the spread of toxic culture. (Perhaps I should cheer myself up by thinking about the spread of a supportive and inclusive culture instead, but it just isn’t happening.)  The idea of mixing modelling paradigms occurred to me.  Can we transfer information from the individual elements we model to have an impact on the underlying social field?

I was imagining the social field as an ocean with a network of buoys floating on its surface. The buoys are separate entities, possibly representing different people.  I saw each buoy as a composite Modelling Architecture Standard (MARS) model, that may consist of many smaller MARS models.  Each buoy is run as a LASAGNE service (or a set of LASAGNE services).  The buoys are connected to other buoys through LASAGNE and can send and receive signals directly to each other, or broadcast signals across the network. The ocean, or social wavefield generator, is a separate service and is similar to a finite-element or spectral-element wave modelling application. The spectral-element grid is constructed as buoys are loaded. There is a one-to-one relationship between grid nodes and buoys.  A grid node has a set of coefficients, (like elastic coefficients in an elastic wave modelling application). The values of the coefficients are provided by the buoys and are plugged into a partial differential equation representing the governing equation of the social ocean. (How to come up with an equation, I have no idea. I’ll have to have a chat with some sociologists.)  Perhaps the values of the coefficients for each buoy gradually change as the simulation runs, or perhaps for simplicity, they remain constant, as if they are some static property of a buoy’s character over a small duration of time.

The waves travelling through the ocean are caused by the combined activity of the buoys. At each timestep, the wave is a numerical solution to the partial differential equation. Energy passes between the ocean nodes.   The “position” of each node changes in the grid. This information is fed back into the network and taken as input by the various buoys, along with the signals coming from other buoys. Bonds between buoys might be broken if the node moves beyond the elastic zone of the bond. Bonds might be created if nodes move within another’s attraction threshold.

Data about the state of the ocean at each timestep could be output and analysed. What might the waves look like when, instead of snapshots of timesteps, we look at snapshots of frequencies?  Can we observe high and low frequency social changes? What do they represent?  Are high frequency changes the result of more elastic activity of the buoys – fast responses or background chatter? Are low frequency waves a sign of more lasting change? What about spatial frequency analysis? I really have no idea.  If we had data from the buoys, could we not only locate the “epicentre” of a particular  wave travelling through the ocean, but start to ascertain a cause, knowing what we do about the characteristics and behavioural responses to the individual  buoys close to the epicentre?

(Sometimes I do my technical diagrams in oil pastels and other traditional art materials because it takes 15 minutes, and it’s less stressful than screaming at drawing applications like Inkscape. ) 

How close are you to being homeless?

 

Adelaide artist and data scientist, Miriam Hochwald invited us to the “Walk a Mile in My Boots”  fundraising event for the Hutt Street Centre for the homeless. As we walked along we chatted about the different factors that lead to women’s homelessness.

I spoke to Miriam about my own brief experience of homelessness, soon after being forced out of my home to escape domestic violence.  In my case,  my background of privilege came into play.  I had people in my life who stepped in to help me, but even then I remember how some relationships became strained because of my neediness. Sometimes I couldn’t face the humiliation of asking for a place to sleep; the insidious victim-blaming and harsh judgement that my requests provoked, so instead,  I slept in my car.  My employers at the time knew there was something seriously wrong, but I was too embarrassed to tell them the whole story. The small gestures they made to help me made a big difference.  For example, they gave me outside-of-hours access and allowed me to use a company computer, the internet and printing facilities for my personal paperwork and social networking.  I know my experience was pretty trivial compared to the people we walked for on Friday, but I’ll never forget those few dark, cold nights and the feeling of hunger and isolation.

As I walked along I wondered if structural violence in the workplace might be another major cause of homelessness – interpersonal structural violence in the form of psychological attacks, bullying and harassment; corporate structural violence in the form of intolerance of diversity, authoritarian silencing of dissent, the promotion of a culture of overwork and the disregard of obligations under WHS legislation.

How many of us would lose our jobs if we chose to speak up?  How many of us would become homeless and how many of us could tap into our privilege to quickly find another job?

But the critical question for me is – how many of us, despite our privilege, choose to remain silent and therefore condone the spread of a toxic culture?

Cathy

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