moved old instructions for external packages to top-level in preparation for nuking...
[CommonLispStat.git] / examples / 00-loadingData.lisp
blobf095521c302f230be6affd58e2b28680e8ea7d7a
1 ;;; -*- mode: lisp -*-
3 ;;; Time-stamp: <2010-06-07 13:55:13 tony>
4 ;;; Creation: <2009-03-12 17:14:56 tony>
5 ;;; File: template.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: Template header file
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 (in-package :cl-user)
17 (cl:defpackage :cls-examples ;; similar setup to cls-user, without test data
18 (:use :common-lisp
19 :lisp-matrix
20 :common-lisp-statistics)
21 (:shadowing-import-from :lisp-stat
22 call-method call-next-method
24 expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan
25 asin acos atan sinh cosh tanh asinh acosh atanh float random
26 truncate floor ceiling round minusp zerop plusp evenp oddp
27 < <= = /= >= > > ;; complex
28 conjugate realpart imagpart phase
29 min max logand logior logxor lognot ffloor fceiling
30 ftruncate fround signum cis
32 <= float imagpart)
33 (:export localized-pathto
34 *chkwgts-df*))
36 ;; start within the cls-examples package, which is similar to cls-user
37 (in-package :cls-examples)
39 ;; we'll be loading from directories in the CLS homedir, so we want to
40 ;; make it easier to reach.
41 (defun localized-pathto (x)
42 "Given a string representing a relative path from the CLS home
43 directory, return a string denoting the complete path.
45 FIXME: UNIX-centric (though might work on Mac OSX). We really want to
46 return a pathspec, not a string/namespec"
47 (check-type x string)
48 (concatenate 'string *cls-home-dir* x))
51 (progn
52 ;; LISP-STAT COMPATIBILITY MODE:
54 ;; FIXME: Need to clean up data examples, licenses, attributions, etc.
55 ;; The following breaks because we should use a package to hold
56 ;; configuration details, and this would be the only package outside
57 ;; of packages.lisp, as it holds the overall defsystem structure.
58 (load-data "iris.lsp") ;; (the above partially fixed).
59 diabetes
60 ;; FIXME above: Diabetes unbound, but it shouldn't be. I think
61 ;; we need to eliminate LispStat v1.
62 (variables))
64 (progn
65 ;; COMMON LISP STATISTICS
66 ;; Importing data from DSV text files.
68 #| We use as an example a simple R datasert, chickwts, which has one
69 nominal categorical variable and one continuous categorical
70 variable. This dataset can be accessed in R as follows:
72 > data(chickwts)
73 > dim(chickwts)
74 [1] 71 2
75 > summary(chickwts)
76 weight feed
77 Min. :108.0 casein :12
78 1st Qu.:204.5 horsebean:10
79 Median :258.0 linseed :12
80 Mean :261.3 meatmeal :11
81 3rd Qu.:323.5 soybean :14
82 Max. :423.0 sunflower:12
86 (defparameter *chickwts-df* (filename.dsv->dataframe (localized-pathto "Data/R-chickwts.csv")))
87 ;; *chickwts-df*
88 (xref *chickwts-df* 1 1) ; => 160
89 (xref *chickwts-df* 40 2) ; => "sunflower"
90 *chickwts-df*)