More on R Difficulties

I’m continuing to have difficulties within R: suddenly rJava doesn’t work and a version is not available for R 3.3.0. Time to re-activate 3.2.4:

sudo port activate R @3.2.4

3.3.0 is still around. Whenever the various R packages have caught up with “Somewhat Educational”, I can re-activate it and then uninstall 3.2.4, whose nickname I have forgotten:

sudo port uninstall R @3.2.4

IRkernel Difficulties

Suddenly, when starting up ipython/Jupyter notebook, the R kernel won’t load. I’m getting the following error:

[W 10:21:13.833 NotebookApp] Notebook Code/notebooks/Syuzhet_of_Small_Stories.ipynb is not trusted
[W 10:21:13.887 NotebookApp] 404 GET /nbextensions/widgets/notebook/js/extension.js?v=20160521102047 (::1) 11.86ms referer=http://localhost:8888/notebooks/Code/notebooks/Syuzhet_of_Small_Stories.ipynb
[I 10:21:14.266 NotebookApp] 302 GET /notebooks/Code/images/R-dendrogram.png (::1) 1.95ms
[I 10:21:14.476 NotebookApp] Kernel started: f2fee2d4-fdc2-4bd7-8cc5-8cd628894807
Error in loadNamespace(name) : there is no package called ‘IRkernel’
Calls: :: ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
Execution halted

Let’s work through these difficulties one line at a time:

Notebook Code/notebooks/Syuzhet_of_Small_Stories.ipynb is not trusted

The documentation for iPython notebook states:

Sometimes re-executing a notebook to generate trusted output is not an option, either because dependencies are unavailable, or it would take a long time. Users can explicitly trust a notebook in two ways:

At the command-line, with:

ipython trust /path/to/notebook.ipynb

After loading the untrusted notebook, with File / Trust Notebook

After running that, I still get the following:

Screen Shot 2016-05-21 at 10.38.34 AM

The next fail appoint appears to be:

Error in loadNamespace(name) : there is no package called ‘IRkernel’

What the what the?

I’ve been running R in iPython notebook for the past week. What happened to the IRkernel package? When I run R and simply try to re-install it:

Warning message:
package ‘IRkernel’ is not available (for R version 3.3.0) 

Ack. At some point MacPorts updated R when I wasn’t paying attention, which is the problem with package managers and it’s really my responsibility. So let’s see if I can un-install 3.3.0 and if that clears things up … too complicated.

BUT there is a solution and it can be done from within R (3.3.0):

install.packages(c('pbdZMQ', 'repr', 'devtools'))  # repr is already on CRAN
devtools::install_github('IRkernel/IRdisplay')
devtools::install_github('IRkernel/IRkernel')
IRkernel::installspec()  # to register the kernel in the current R installation

4 simple steps and everything is hunky-dory (why one would want a muscular skiff, I don’t know).

Every time I have to handle something that somehow just brushes past Java, I have a bad time. This time it was getting Matthew Jockers syuzhet R package up and running on my machine with a clean install of Mac OS 10.11 on it. The craziness is still with me, witness this:

Which Java? El Capitan is conflicted.

Which Java? El Capitan is conflicted.

But after many, many attempts to install.packages("syuzhet") being met withinstallation of package ‘syuzhet’ had non-zero exit statusand the same forrJava`, it appears the following may have worked:

install.packages("rJava", type="mac.binary")

More Notes on Jupyter Notebook

I used [MacPorts][], [as always][], to install the new code for Jupyter:

port install py34-jupyter

*Note: you may need to prepend `sudo` to install software on your setup.*

But the new command `jupyter notebook` only returned `-bash: jupyter: command not found` for me. I tried various alternatives, but got nowhere until I returned to `ipython notebook`. *Presto.* And even better, now I have this:

Python or R?

Python or R?

Note: make sure you install Jupyter as per the instructions above before attempting to install the packages below, which require `zmq` and will, in my experience, fail to install as a result. (I also tend to run R as `sudo` to do this, which may be a holdover from some previous troubleshooting.)

With Jupyter notebook installed, enter the following in the R shell:

install.packages(c(‘rzmq’,’repr’,’IRkernel’,’IRdisplay’),
repos = c(‘http://irkernel.github.io/’,
getOption(‘repos’)))

IRkernel::installspec()

See [iRkernel][] for more information.

Once you’re done: `ipython notebook` and you’re done.

[MacPorts]: https://www.macports.org
[as always]: http://johnlaudun.org/20121230-macports-the-key-to-python-happiness/
[iRkernel]: http://irkernel.github.io/installation/

Ben Marwick has an R script that converts CSV word counts into “bag of words” text files. His response is part of a [larger conversation at Digital Humanities Q & A started by Chris Forster](http://digitalhumanities.org/answers/topic/topic-modeling-mallet-with-jstor-data-for-research).