A bit more philosophy and task for visualization, in response to Peter S. Still...
[CommonLispStat.git] / examples / data-manipulation.lisp
blob802f6398caf0e9b78e3589336e9b2cac30ec66da
1 ;;; -*- mode: lisp -*-
3 ;;; Time-stamp: <2009-07-14 14:29:23 tony>
4 ;;; Creation: <2009-03-12 17:14:56 tony>
5 ;;; File: data-manipulation.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: demo on dataframe and matrix work.
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
16 ;;; version.. Think, "21st Century Schizoid Man".
18 (in-package :ls-user) ; we do this in the CLS user playground, so we
19 ; have access to example data.
21 ;;; Guidelines:
23 ;; use license accord to requirements (based on included packages, or
25 ;; use DEFPARAMETER and special variables to define useful
26 ;; structures.
28 ;; Be prepared to have a clean-up function (or attach/wrap a cleanup
29 ;; hook.
31 (defpackage :cls-ex-datamanip
32 (:use :common-lisp
33 :lisp-matrix
34 :common-lisp-statistics)
36 (:shadowing-import-from :lisp-stat call-method call-next-method
38 expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan
39 asin acos atan sinh cosh tanh asinh acosh atanh float random
40 truncate floor ceiling round minusp zerop plusp evenp oddp
41 < <= = /= >= > > ;; complex
42 conjugate realpart imagpart phase
43 min max logand logior logxor lognot ffloor fceiling
44 ftruncate fround signum cis
46 <= float imagpart))
48 (in-package :cls-ex-datamanip)
50 ;; There are two initial forms for most datasets which are in
51 ;; cases-by-variables format -- listoflist structure and lisp
52 ;; arrays.
54 (defparameter *ex-lol* '((11d0 12d0 13d0 14d0)
55 (21d0 22d0 23d0 24d0)
56 (31d0 32d0 33d0 34d0)))
58 (defparameter *ex-ary* #2A((11d0 12d0 13d0 14d0)
59 (21d0 22d0 23d0 24d0)
60 (31d0 32d0 33d0 34d0)))
64 ;; Matrices
66 (make-matrix 3 4 :initial-contents *ex-lol*)
67 (make-matrix 3 4 :initial-contents *ex-ary*)
69 ;; Dataframes
71 (make-dataframe *ex-ary*)
72 (make-dataframe (cls-data-listoflist:listoflist->array *ex-lol*))
74 ;; need to make "make-dataframe" generic.
75 ;; (make-dataframe *ex-lol*) ;; error