README.md

Graxxia

Graxxia is a library adds data analysis features to Groovy, similar to languages such as
R, Julia, etc, and also to libraries such as Pandas for Python.

It should be emphasised that there is nearly nothing in Graxxia itself that is
not just a wrapper around other existing libraries. For example Matrix support
all comes from Apache commons-math, parsing of CSV and TSV (tab separated) files
comes from OpenCSV and GroovyCSV, etc.

What can you do with Graxxia? You can get just a few interesting things:

Obviously this is not even remotely comparable to what is available for data
analysis in the other languages mentioned above. However these classes can
make doing simple data analysis in Groovy quite powerful and in some cases
compares very favorably to doing it in other languages. Combined with the
Groovy Shell, it becomes quite useful for interactive data analysis.

Quick Try Out

Graxxia is now available from Maven Central! That means you can use it without any download or
compile via the @Grab annotation. To give Graxxia a try, start a Groovy shell:

Building and Using It from Source

Put it in your classpath. A nice way to play around with it is with groovysh. So, for example:

groovysh -cp build/libs/graxxia.jar

Note: this build process builds a fully self-contained jar file that contains
all dependencies (sometimes called a 'fat' jar). In rare situations these could
conflict with other libraries already in your class path.

Note: if you encounter problems, please check that your Groovy version matches
that specified in the build.gradle file. Graxxia should work with versions of
Groovy > 2.2, but problems can occur if your version doesn't match (this can
happen even between point releases of the same major version, unforutnately).

Examples

The heart of Graxxia is the Matrix class. Start by importing the Graxxia classes:

So straight away you can see, there are some conversions between arrays, and
lists of doubles that are built in for you. In general you can just take any 2
dimensional array / list combination and turn it into a Matrix. In fact, all
Graxxia cares about is that they are Iterable, so you can even feed a Matrix
dynamically if you like.

We can access the elements, as you would expect, via indexing with row and column respectively:

groovy:000> m[2][1]
===> 4.0

An important thing to point out here is that everything is using zero-based indexing, not 1-based.

A whole row is accessed by omitting the second index:

groovy:000> m[2] as String
===> [10.0, 4.0, 3.0]

A whole column is accessed by omitting the first index:

groovy:000> m[][1]
===> [3.0,6.0,4.0]

Graxxia's Matrix class returns a special MatrixColumn object for column access. You can treat it as a List, but it is actually working under the covers to reflect accessors back into the original Matrix from which the column came. That is, you are not looking at a copy of the data, you are looking at the actual data. No copy is made when you access by column, even thought the data is stored natively in row format.