From dd6a29cdc413bde451be3a6d8d27132f7d5cf577 Mon Sep 17 00:00:00 2001 From: AJ Rossini Date: Wed, 26 Mar 2008 18:17:49 +0100 Subject: [PATCH] working but super-primitive dataset type. However, read the comments for how this can be built up a bit more. --- data-clos.lisp | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 84 insertions(+), 5 deletions(-) diff --git a/data-clos.lisp b/data-clos.lisp index fcc8be5..7611653 100644 --- a/data-clos.lisp +++ b/data-clos.lisp @@ -30,12 +30,75 @@ (in-package :lisp-stat-data-clos) + +;; Need to figure out typed vectors. We then map a series of typed +;; vectors over to tables where columns are equal typed. In a sense, +;; this is a relation (1-1) of equal-typed arrays. For the most part, +;; this ends up making the R data.frame into a relational building +;; block (considering 1-1 mappings using row ID as a relation). + + +(defclass table ()) + +(defclass relation ()) + (defclass dataset () - ((store :initform (array) :initarg :storage :accessor storage) - (documentation :initform (list) :initarg :doc :accessor documentation) - (case-labels :initform (list) :initarg :y :accessor y) - (var-labels :initform (list) :initarg :y :accessor y)) - (:documentation "Standard Cases by Variables Dataset.")) + ((store :initform nil + :initarg :storage + :accessor dataset) + (documentation-string :initform nil + :initarg :doc + :accessor doc-string) + (case-labels :initform nil + :initarg :case-labels + :accessor case-labels) + (var-labels :initform nil + :initarg :var-labels + :accessor var-labels))) +;; (:documentation "Standard Cases by Variables Dataset.")) + +;; Need to set up dataset as a table or a relation. One way or +;; another it should all work out. TODO: How do we do multiple +;; inheritance or composite structures? + +(defvar my-ds-1 nil + "test ds for experiment.") +(setf my-ds-1 (make-instance 'dataset)) +my-ds-1 + +(defvar my-ds-2 nil + "test ds for experiment.") +(setf my-ds-2 (make-instance 'dataset + :storage #2((1 2 3 4 5) (10 20 30 40 50)) + :doc "This is an interesting dataset" + :case-labels (list "a" "b" "c" "d" "e") + :var-labels (list "x" "y"))) +my-ds-2 +(dataset my-ds-2) +(doc-string my-ds-2) +(case-labels my-ds-2) +(var-labels my-ds-2) + +(defun print-structure-table (ds) + "example of what we want the methods to look like. Should be sort +of like a spreadsheet if the storage is a table." + (print-as-row (var-labels ds)) + (let ((j -1)) + (dolist (i (case-labels ds)) + (princ "%i %v" i (row-extract (dataset ds) (incr j)))))) + +(defun print-structure-relational (ds) + "example of what we want the methods to look like. Should be sort +of like a graph of spreadsheets if the storage is a relational +structure." + (dolist (k (relations ds)) + (print-as-row (var-labels ds)) + (let ((j -1)) + (dolist (i (case-labels ds)) + (princ "%i %v" i (row-extract (dataset ds) (incr j)))))) + + + (defgeneric extract (dataform what into-form)) @@ -47,3 +110,19 @@ (defclass data-format()) +(defun transpose (x) + "map NxM to MxN.") + +(defun reorder-by-rank (x order &key (by-row t)) + " .") + +(defun reorder-by-permutation (x perm &key (by-row t)) + " .") + +;;; need a setter for case and var names. I think we can do that in +;;; the class definitinon? + + + + + -- 2.11.4.GIT