Cleaning up Examples directory. numbered examples work up to the "FIXME" markers
[CommonLispStat.git] / examples / 04-dataManipulation.lisp
blobb0dccaf803f5b48fbb31ae1f455e2788113d878b
1 ;;; -*- mode: lisp -*-
3 ;;; Time-stamp: <2012-10-11 16:12:48 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".
19 ;; we do this in the CLS user playground, so we have access to example
20 ;; data.
21 (in-package :cls-user)
23 ;;; Guidelines:
25 ;; use license accord to requirements (based on included packages, or
27 ;; use DEFPARAMETER and special variables to define useful
28 ;; structures.
30 ;; Be prepared to have a clean-up function (or attach/wrap a cleanup
31 ;; hook.
33 (defpackage :cls-ex-datamanip
34 (:use :common-lisp
35 :lisp-matrix
36 :common-lisp-statistics)
38 (:shadowing-import-from :lisp-stat call-method call-next-method
40 expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan
41 asin acos atan sinh cosh tanh asinh acosh atanh float random
42 truncate floor ceiling round minusp zerop plusp evenp oddp
43 < <= = /= >= > > ;; complex
44 conjugate realpart imagpart phase
45 min max logand logior logxor lognot ffloor fceiling
46 ftruncate fround signum cis
48 <= float imagpart))
50 (in-package :cls-ex-datamanip)
52 ;; There are two initial forms for most datasets which are in
53 ;; cases-by-variables format -- listoflist structure and lisp
54 ;; arrays.
56 (defparameter *ex-lol* '((11d0 12d0 13d0 14d0)
57 (21d0 22d0 23d0 24d0)
58 (31d0 32d0 33d0 34d0)))
60 (defparameter *ex-ary* #2A((11d0 12d0 13d0 14d0)
61 (21d0 22d0 23d0 24d0)
62 (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*)) ;; FIXME
73 ;; (make-dataframe *ex-lol*) ;; error
75 ;;; "make-dataframe2" is generic -- FIXME: but it is not yet exported!
76 ;; FIXME: (make-dataframe2 *ex-ary*)
77 ;; FIXME: (make-dataframe2 *ex-lol*)) ;; FIXME