Chapter 8. Working with Mathematica and R

In this chapter, we will cover the following recipes:

  • Setting up Mathematica to talk to Clojuratica for Mac OS X and Linux
  • Setting up Mathematica to talk to Clojuratica for Windows
  • Calling Mathematica functions from Clojuratica
  • Sending matrixes to Mathematica from Clojuratica
  • Evaluating Mathematica scripts from Clojuratica
  • Creating functions from Mathematica
  • Setting up R to talk to Clojure
  • Calling R functions from Clojure
  • Passing vectors into R
  • Evaluating R files from Clojure
  • Plotting in R from Clojure

Introduction

Clojure and Incanter are powerful, flexible tools, but they're not the only ones available. We might have some analyses already implemented in another system, for instance, and we'd like to use them even though we're using Clojure everywhere else.

Mathematica (http://www.wolfram.com/mathematica/) is one of these tools. It's a software environment produced by Wolfram Research. It does complex mathematics and graphing as well as many other things. It's a powerful tool made more powerful and customizable thanks to its programming language.

R (http://www.r-project.org/) is also another such tool. It's an open source system that specializes in statistical computing. It's also a programming language, and thanks to an active user community, there are a lot of contributed packages for almost any statistical task.

Both these systems are powerful and complex in their own right, and we won't be able to go into details of how to use them or their features in this chapter. However, if you already have some analyses implemented in either Mathematica or R or you want to learn one of these and you wish to incorporate them into a Clojure-driven workflow, this chapter should show you the way.

Unfortunately, interoperability—interfacing directly between different computer systems, such as Clojure and Mathematica or R—is a difficult and often tricky task. We can fall back on shuffling data back and forth using CSV files, but for more power and flexibility, having a direct connection between the two systems is unmatched, and it's often worth the effort and frustration in order to have a more direct and richer interface. In this chapter, we'll talk about how to set up this interoperability and how to use each system from Clojure to do simple tasks.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.188.10.1