X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Fstats%2Fnpar-summary.c;h=d626dffac5f72075a582c370cb5940ec3845e2d1;hb=b5c82cc9aabe7e641011130240ae1b2e84348e23;hp=c752d503bbbde6af9eeb0bd3036656e6de2c6019;hpb=c3ac5a8af9c449072c7e872ca70a78c1755ae309;p=pspp-builds.git diff --git a/src/language/stats/npar-summary.c b/src/language/stats/npar-summary.c index c752d503..d626dffa 100644 --- a/src/language/stats/npar-summary.c +++ b/src/language/stats/npar-summary.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 2006 Free Software Foundation, Inc. + Copyright (C) 2006, 2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -15,6 +15,8 @@ along with this program. If not, see . */ #include + +#include #include #include #include @@ -45,7 +47,7 @@ npar_summary_calc_descriptives (struct descriptives *desc, double maximum = -DBL_MAX; double var; struct moments1 *moments = moments1_create (MOMENT_VARIANCE); - struct ccase c; + struct ccase *c; const struct variable *v = *vv++; struct casereader *pass; @@ -54,14 +56,14 @@ npar_summary_calc_descriptives (struct descriptives *desc, &v, 1, filter, NULL, NULL); pass = casereader_create_filter_weight (pass, dict, NULL, NULL); - while (casereader_read(pass, &c)) + while ((c = casereader_read (pass)) != NULL) { - double val = case_num (&c, v); - double w = dict_get_case_weight (dict, &c, NULL); + double val = case_num (c, v); + double w = dict_get_case_weight (dict, c, NULL); minimum = MIN (minimum, val); maximum = MAX (maximum, val); moments1_add (moments, val, w); - case_destroy (&c); + case_unref (c); } casereader_destroy (pass); @@ -97,13 +99,12 @@ do_summary_box (const struct descriptives *desc, int columns = 1 ; struct tab_table *table ; - if ( desc ) columns += 5; if ( quartiles ) columns += 3; table = tab_create (columns, 2 + n_vars, 0); - tab_dim (table, tab_natural_dimensions); + tab_dim (table, tab_natural_dimensions, NULL); tab_title (table, _("Descriptive Statistics")); @@ -152,15 +153,19 @@ do_summary_box (const struct descriptives *desc, col++; } + for ( v = 0 ; v < n_vars ; ++v ) { - tab_text (table, 0, 2 + v, TAT_NONE, var_to_string (vv[v])); + const struct variable *var = vv[v]; + const struct fmt_spec *fmt = var_get_print_format (var); + + tab_text (table, 0, 2 + v, TAT_NONE, var_to_string (var)); - tab_float (table, 1, 2 + v, TAT_NONE, desc[v].n, 8, 0); - tab_float (table, 2, 2 + v, TAT_NONE, desc[v].mean, 8, 3); - tab_float (table, 3, 2 + v, TAT_NONE, desc[v].std_dev, 8, 3); - tab_float (table, 4, 2 + v, TAT_NONE, desc[v].min, 8, 3); - tab_float (table, 5, 2 + v, TAT_NONE, desc[v].max, 8, 3); + tab_double (table, 1, 2 + v, TAT_NONE, desc[v].n, fmt); + tab_double (table, 2, 2 + v, TAT_NONE, desc[v].mean, fmt); + tab_double (table, 3, 2 + v, TAT_NONE, desc[v].std_dev, fmt); + tab_double (table, 4, 2 + v, TAT_NONE, desc[v].min, fmt); + tab_double (table, 5, 2 + v, TAT_NONE, desc[v].max, fmt); }