3 ;;; File: data-clos.lisp
4 ;;; Author: AJ Rossini <blindglobe@gmail.com>
5 ;;; Copyright: (c)2008, AJ Rossini. BSD, LLGPL, or GPLv2, depending
7 ;;; Purpose: data package for lispstat
8 ;;; Time-stamp: <2008-03-12 17:18:42 user>
9 ;;; Creation: <2008-03-12 17:18:42 user>
11 ;;; What is this talk of 'release'? Klingons do not make software
12 ;;; 'releases'. Our software 'escapes', leaving a bloody trail of
13 ;;; designers and quality assurance people in its wake.
15 ;;; This organization and structure is new to the 21st Century
20 ;;; redoing regression in a CLOS based framework.
21 ;;; See regression.lsp for basis of work.
25 (defpackage :lisp-stat-data-clos
27 :clem
;;?? or :matlisp , or :...?
29 (:export dataset extract set
))
31 (in-package :lisp-stat-data-clos
)
34 ;; Need to figure out typed vectors. We then map a series of typed
35 ;; vectors over to tables where columns are equal typed. In a sense,
36 ;; this is a relation (1-1) of equal-typed arrays. For the most part,
37 ;; this ends up making the R data.frame into a relational building
38 ;; block (considering 1-1 mappings using row ID as a relation).
43 (defclass relation
())
49 (documentation-string :initform nil
52 (case-labels :initform nil
54 :accessor case-labels
)
55 (var-labels :initform nil
57 :accessor var-labels
)))
58 ;; (:documentation "Standard Cases by Variables Dataset."))
60 ;; Need to set up dataset as a table or a relation. One way or
61 ;; another it should all work out. TODO: How do we do multiple
62 ;; inheritance or composite structures?
65 "test ds for experiment.")
66 (setf my-ds-1
(make-instance 'dataset
))
70 "test ds for experiment.")
71 (setf my-ds-2
(make-instance 'dataset
72 :storage
#2((1 2 3 4 5) (10 20 30 40 50))
73 :doc
"This is an interesting dataset"
74 :case-labels
(list "a" "b" "c" "d" "e")
75 :var-labels
(list "x" "y")))
82 (defun print-structure-table (ds)
83 "example of what we want the methods to look like. Should be sort
84 of like a spreadsheet if the storage is a table."
85 (print-as-row (var-labels ds
))
87 (dolist (i (case-labels ds
))
88 (princ "%i %v" i
(row-extract (dataset ds
) (incr j
))))))
90 (defun print-structure-relational (ds)
91 "example of what we want the methods to look like. Should be sort
92 of like a graph of spreadsheets if the storage is a relational
94 (dolist (k (relations ds
))
95 (print-as-row (var-labels ds
))
97 (dolist (i (case-labels ds
))
98 (princ "%i %v" i
(row-extract (dataset ds
) (incr j
))))))
103 (defgeneric extract
(dataform what into-form
))
105 (defmethod extract ((ds dataset
) what into-form
)
106 (reshape (get ds what
) into-form
))
110 (defclass data-format
())
116 (defun reorder-by-rank (x order
&key
(by-row t
))
119 (defun reorder-by-permutation (x perm
&key
(by-row t
))
122 ;;; need a setter for case and var names. I think we can do that in
123 ;;; the class definitinon?