notes and paren matching.
[CommonLispStat.git] / examples / loading-data.lisp
blob0d6d34d686f6ac4366aebfac4852b3a425b1e276
1 ;;; -*- mode: lisp -*-
3 ;;; Time-stamp: <2010-01-15 07:56:57 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 ;; start within the common-lisp-stat-user
16 (in-package :cls-user)
18 ;; we'll be loading from directories in the CLS homedir, so we want to
19 ;; make it easier to reach.
20 (defun localized-pathto (x)
21 "return a string denoting the complete path.
22 FIXME: UNIX-centric (though might work on Mac OSX). Might want to
23 return a pathspec, not a string/namespec"
24 (check-type x string)
25 (concatenate 'string *cls-home-dir* x))
29 (progn
30 ;; LISP-STAT COMPATIBILITY MODE:
32 ;; FIXME: Need to clean up data examples, licenses, attributions, etc.
33 ;; The following breaks because we should use a package to hold
34 ;; configuration details, and this would be the only package outside
35 ;; of packages.lisp, as it holds the overall defsystem structure.
36 (load-data "iris.lsp") ;; (the above partially fixed).
37 diabetes
38 (variables))
43 (progn
44 ;; COMMON LISP STATISTICS
46 ;; Importing data from DSV text files.
50 We use as an example a simple R datasert, chickwts, which has one
51 nominal categorical variable and one continuous categorical
52 variable. This dataset can be accessed in R as follows:
54 > data(chickwts)
55 > dim(chickwts)
56 [1] 71 2
57 > summary(chickwts)
58 weight feed
59 Min. :108.0 casein :12
60 1st Qu.:204.5 horsebean:10
61 Median :258.0 linseed :12
62 Mean :261.3 meatmeal :11
63 3rd Qu.:323.5 soybean :14
64 Max. :423.0 sunflower:12
68 (defparameter *chickwts-df* (filename.dsv->dataframe (localized-pathto "Data/R-chickwts.csv")))
69 ;; *chickwts-df*
70 (xref *chickwts-df* 1 1) ; => 160
71 (xref *chickwts-df* 40 2) ; => "sunflower"