Category Archives: Uncategorized

Java 1.8 Setup for R and R Studio

Why is this so hard! There are a lot of posts out there all trying to help people get java packages working with R Studio and R on MacOSX (El Capitan, 10.11.5 in my case). I also have Java 8 installed and would prefer to use that.

This post, seemed to help me understand best what the issues were but alas, didn’t get me running the packages I wanted: FSelector which depends on RWeka and rJava. The R config file, /Library/Frameworks/R.framework/Versions/3.3/Resources/etc/Renvironis an important key, but setting variables there did not help in the way that post suggested. Here is what I did.

With a clean Renviron file, and both jdk 1.6 (RStudio seems to require this to do anything with java) from apple, and jdk1.8 from Oracle installed, jdk 8 as the default, I ran

sudo R CMD javareconf

if successful you will see a compiled program success in the output. Unfortunately you aren’t done yet. Start R and use

install.packages(‘rJava’, type=’source)

It was downloaded, compiled and ran a test compilation for me, and this worked for me but there are a couple of steps needed before a full package can actually be executed. First I needed to install X, from XQuartz.org. This will install X libraries under /opt/X11 that java looks for at run time. If you were having problems running the test program in the previous step, this may solve it for you.

Finally, you do need to link the jvm shared dylib into a place the R can find it.

ln -f -s $(/usr/libexec/java_home)/jre/lib/server/libjvm.dylib /usr//locallib

and finally, we actually do need to edit the Renviron file mentioned earlier to tell the dyn loader where to find the library. Edit the end of the file so it looks like this (/Library/Frameworks/R.framework/Versions/3.3/Resources/etc/Renviron):

Local Variables: ***
### mode: sh ***
### sh-indentation: 2 ***
 DYLD_LIBRARY_PATH=/usr/local/lib:/usr/lib
### End: ***
## CRAN R ships with qpdf inside so use it unless directed otherwise
R_QPDF=${R_QPDF-'/Library/Frameworks/R.framework/Resources/bin/qpdf'}

After that I was able to open R Studio and load and start FSelector

install.packages(‘FSelector’)

library(FSelector)

gains <- information.gain(someform~., somedata.table)

I hope this helps somebody!

Advertisements

Introduction to Docker talk and follow up

My slides and the code I used for the Introduction to Docker talk most recently done at http://newcodecamp.com are available in my github profile at https://github.com/panmanphil/introduction-to-docker

Thanks to all who came! One of the most interesting parts of the talk, helped by the smart people in the room who asked great questions, were the questions about when it is appropriate to use Docker or not. Docker is most often talked about in relationship to microservices, the architectural pattern where you split your application or system into many small, independent services, For this it is easy to say Docker is a great match. Lots of small applications running on a cluster of docker hosts is what it was built for. Another really useful thing is to use docker as an alternative to installing tons of software on your development box, or even on your servers. The files in a Docker image are completely isolated from the host and can be cleanly added and removed at will. You don’t have to create a linux, windows, macox, other versions of your software if people expect to use it via docker.

In the “Docker all the things” camp, you would hear the call to move everything this way, something you hear anyway when a new technology is early in the hype curve. I can say that in my experience so far, there have been some real wins running things in containers:

  • small myql instances used for small apps
  • redis running locally for development
  • riak running locally was much easier to test in docker

On the other hand, while it may have been easier to run jenkins locally in docker, running jenkins in docker at AWS has not been a clear winner: a dedicated host may have made more sense, perhaps setup with vagrant and bash or even ansible (which I now know enough about to say that, thanks Mike Putnam!). The image is over 1GB in size, and it consumes all the memory and cpu the host has available to run Jenkins and one agent. If we could get the image size down, running multiple agents in Docker might make sense though. Life is trade offs, no?

This is really the next phase of my longer term evaluation of Docker, to understand and to be able to more clearly express when it’s great, good and terrible to use Docker.

Twin Cities Code Camp: Evolving REST to Hypermedia designs

In advance of my talk here is the sample code and slides for Twin Cities Code Camp 2014. The premise of the talk is the move to having web api’s that are primarily data oriented to those those that include actions appropriate for the context and time via links. Using HAL, it is possible, but you also need a state machine to “calculate” the appropriate links. For that I am releasing my pet side project to accomplish that as part of this talk.

The demo source is available at github. There is a branch of the framework in that repo in a zip file. I will maintain the main branch also at github, restructuring it now that the talk is over and I’m not wrasslin’ with nuget and the directory structure I’d like to use.

Note that the version of WebApi.HAL i’m using is not the current version. I had to add support for a few key HAL components, curies, and type and profile attributes, to accomplish what I needed. These have been submitted as pull requests, but they are still working through some previous pull requests so haven’t incorporated them as of yet. Use my fork if you want the source. For now I used a nuget package included in the zip. You will have to add a package source source to use it.