make sure we put the dataframes into the dataframe pacakage. Whoops.
[CommonLispStat.git] / src / data / dataframe-matrixlike.lisp
blobb49014ef79ae888fa7f7fd99088bb9198336097d
1 ;;; -*- mode: lisp -*-
3 ;;; Time-stamp: <2009-09-21 17:03:20 tony>
4 ;;; Creation: <2009-03-12 17:14:56 tony>
5 ;;; File: dataframe-matrixlike.lisp
6 ;;; Author: AJ Rossini <blindglobe@gmail.com>
7 ;;; Copyright: (c)2009--, AJ Rossini. BSD, LLGPL, or GPLv2, depending
8 ;;; on how it arrives.
9 ;;; Purpose: Uses the lisp-matrix dataframe instance for storage.
10 ;;; Useful if we only have numerical data and no missing
11 ;;; data, strings, or categorical stuff...
13 ;;; What is this talk of 'release'? Klingons do not make software
14 ;;; 'releases'. Our software 'escapes', leaving a bloody trail of
15 ;;; designers and quality assurance people in its wake.
17 ;;; This organization and structure is new to the 21st Century
18 ;;; version.. Think, "21st Century Schizoid Man".
20 (in-package :cls-dataframe)
22 ;;; DATAFRAME-MATRIXLIKE
23 ;;;
24 ;;; example/implementatin of using lisp-matrix datastructures for
25 ;;; dataframe storage.
28 (defclass dataframe-matrixlike (dataframe-like)
29 ((store :initform nil
30 :initarg :storage
31 :type matrix-like
32 :accessor dataset
33 :documentation "Data storage: typed as matrix-like
34 (numerical only)."))
35 (:documentation "example implementation of dataframe-like using storage
36 based on lisp-matrix structures."))
38 (defmethod nrows ((df dataframe-matrixlike))
39 "specializes on inheritance from matrix-like in lisp-matrix."
40 (matrix-dimension (dataset df) 0))
42 (defmethod ncols ((df dataframe-matrixlike))
43 "specializes on inheritance from matrix-like in lisp-matrix."
44 (matrix-dimension (dataset df) 1))
46 ;;; *** FIXME: change mref to xref when we establish lisp-matrix
47 ;;; change to use xarray access facility. Need to dummy-proof the
48 ;;; following.
49 (defmethod xref ((df dataframe-matrixlike) &rest subscripts)
50 "Returns a scalar in array, in the same vein as aref, mref, vref, etc.
51 idx1/2 is row/col or case/var."
52 (mref (dataset df) (elt subscripts 0) (elt subscripts 1)))
54 (defmethod (setf xref) (value (df dataframe-matrixlike) &rest subscripts)
55 "Sets a value for df-ml."
56 ;; NEED TO CHECK TYPE!
57 ;; (check-type val (elt (vartype df) index2))
58 (setf (mref (dataset df) (elt subscripts 0) (elt subscripts 1)) value))