Database Reference
In-Depth Information
3.
Now that it's a matrix, we can treat it like a sequence of rows. Here, we pass it to
first in order to get the irst row, take in order to get a subset of the matrix,
and count in order to get the number of rows in the matrix:
user=> (first va-matrix)
A 1x3 matrix
-------------
8.19e+03 4.27e+03 2.06e+03
user=> (count va-matrix)
591
4.
We can also use Incanter's matrix operators to get the sum of each column, for
instance. The plus function takes each row and sums each column separately:
user=> (reduce plus va-matrix)
A 1x3 matrix
-------------
5.43e+06 2.26e+06 1.33e+06
How it works…
The to-matrix function takes a dataset of loating-point values and returns a compact
matrix. Matrices are used by many of Incanter's more sophisticated analysis functions,
as they're easy to work with.
There's more…
In this recipe, we saw the plus matrix operator. Incanter deines a full suite of these. You can
learn more about matrices and see what operators are available at https://github.com/
liebke/incanter/wiki/matrices .
See also…
F The Selecting columns with $ recipe in this chapter has more information on how to
select speciic columns from a dataset
 
Search WWH ::




Custom Search