(defun show-data (vars &optional varnames) (let* ( (plotask (send text-item-proto :new "Pick plot type")) (plotget (send choice-item-proto :new (list "Scatterplot" "Line Plot" "Boxplot" "Histogram" "Spin Plot" "Scatterplot Matrix" "Quantile Plot"))) (varnames (if varnames varnames (mapcar #'(lambda (i) (format nil "Var ~a" i)) (iseq (length vars))))) (ok (send button-item-proto :new "Plot it Baby" :action #'(lambda () (let* ( (val (send plotget :value)) ) (case val (0 (let* ( (varlist (get-vars vars varnames 2)) (varvals (first varlist)) (varname (second varlist)) (cond (= 1 (length (remove-duplicates (mapcar #'length varvals))))) ) (if cond (setf scatter (plot-points (first varvals) (second varvals) :variable-labels varname :title (concatenate 'string (elt varname 0) " vs " (elt varname 1)))) (error "Sequences not of same length")))) (1 (let* ( (varlist (get-vars vars varnames 2)) (varvals (first varlist)) (varname (second varlist)) (cond (= 1 (length (remove-duplicates (mapcar #'length varvals))))) ) (if cond (setf line (plot-lines (first varvals) (second varvals) :variable-labels (second vars) :title (concatenate 'string (elt varname 0) " vs " (elt varname 1)))) (error "Sequences not of same length")))) (2 (let* ( (varlist (get-vars vars varnames 1)) (varvals (first varlist)) (varname (second varlist)) ) (setf line (boxplot varvals :title (first varname))))) (3 (let* ( (varlist (get-vars vars varnames 1)) (varvals (first varlist)) (varname (second varlist)) ) (setf line (histogram varvals :title (first varname))))) (4 (let* ( (varlist (get-vars vars varnames 3)) (varvals (first varlist)) (varname (second varlist)) (cond (= 1 (length (remove-duplicates (mapcar #'length varvals))))) ) (if cond (setf line (spin-plot varvals :variable-labels varname :title (concatenate 'string (elt varname 0) " vs " (elt varname 1) " vs " (elt varname 2)))) (error "Sequences not of same length")))) (5 (let ( (cond (= 1 (length (remove-duplicates (mapcar #'length vars))))) ) (if cond (setf scatmat (scatterplot-matrix vars :variable-labels varnames)) (error "Sequences not of same length")))) (6 (let* ( (varlist (get-vars vars varnames 1)) (varvals (first varlist)) (varname (second varlist)) ) (setf qplot (quantile-plot (first varvals) :title (first varname)))))))))) ) (send dialog-proto :new (list plotask plotget ok)) ) ) (defun get-vars (vars varnames n) (let* ( (var1ask (send text-item-proto :new "Var 1")) (var2ask (send text-item-proto :new "Var 2")) (var3ask (send text-item-proto :new "Var 3")) (var1get (send choice-item-proto :new varnames)) (var2get (send choice-item-proto :new varnames)) (var3get (send choice-item-proto :new varnames)) (ok (send modal-button-proto :new "Ok" :action #'(lambda () (let* ( (var1 (send var1get :value)) (var2 (send var2get :value)) (var3 (send var3get :value)) ) (mapcar #'(lambda (x) (select x (select (list var1 var2 var3) (iseq n)))) (list vars varnames)))))) (dialog (send modal-dialog-proto :new (list (select (list var1ask var2ask var3ask) (iseq n)) (select (list var1get var2get var3get) (iseq n)) ok))) ) (send dialog :modal-dialog) ) ) (defmeth dialog-proto :close () (exit) ) (show-data '( (21 22 20 23 21 20 19 21 20 14 23 24 22 22 20 23 20 21 19 20 22 16 22 21 22 21 21 23 19 22 19 20 22 19 21 22 21 21 22 21 21 22 17 22 21 18 22) (2231006 1898423 1474785 1626035 1516329 1516968 1512424 1527011 1076158 798341 1609606 1253164 1337159 1532810 1318521 1502054 1393093 1564212 1474861 1554116 1572284 1129834 1781470 1659206 1752172 1685938 1644110 1746709 1754081 1853363 1754081 1692441 1801019 1702335 1678305 1527744 1980876 1941688 1889106 1741465 1832510 1926233 1670136 1948290 1627594 1655290 1844604) (106238 86291 73739 70697 72706 75849 79601 72714 53807 57024 69982 52215 60779 69673 65926 65306 69654 74486 77624 77705 71467 70614 80975 79009 79644 80282 78290 75943 92320 84243 92320 84622 81864 89596 79919 69442 94327 92461 85868 82926 87262 87556 98243 88558 77504 91960 83845) (6729 5751 6711 7069 7134 5954 5447 6558 5222 4150 6765 6681 7016 7440 6264 7337 7271 6694 5795 7105 6613 5258 7664 6716 7614 7652 7513 7862 7182 6855 7182 6830 6552 7318 6679 6637 7912 7319 7803 8126 7489 7986 6020 6442 7937 6685 7470) (747 821 745 785 792 744 680 728 746 691 751 835 779 826 783 815 807 743 724 789 734 657 851 839 846 850 834 873 798 761 798 758 819 813 834 737 879 914 867 902 832 887 860 920 881 835 830) (9 7 9 9 9 8 8 9 7 6 9 8 9 9 8 9 9 9 8 9 9 8 9 8 9 9 9 9 9 9 9 9 8 9 8 9 9 8 9 9 9 9 7 7 9 8 9) (1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47)) (list "ncol1a" "tincome1a" "ainc1a" "inc1a" "ai1a" "n1a" "time"))