From: John Darrington Date: Sun, 15 Aug 2010 15:50:14 +0000 (+0200) Subject: oneway.c: Use the categoricals struct to calculate number of groups X-Git-Tag: sav-api~71 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?p=pspp;a=commitdiff_plain;h=a9c5233f04317a5ace5e6dcbe3cc61a9f07d57c0 oneway.c: Use the categoricals struct to calculate number of groups --- diff --git a/src/language/stats/oneway.c b/src/language/stats/oneway.c index f481c69dc1..e88a9542ec 100644 --- a/src/language/stats/oneway.c +++ b/src/language/stats/oneway.c @@ -400,17 +400,13 @@ run_oneway (const struct oneway_spec *cmd, struct ccase *c; struct oneway_workspace ws; - - { - ws.vws = xmalloc (cmd->n_vars * sizeof (*ws.vws)); - ws.dd_total = xmalloc (sizeof (struct descriptive_data) * cmd->n_vars); + ws.actual_number_of_groups = 0; + ws.vws = xmalloc (cmd->n_vars * sizeof (*ws.vws)); + ws.dd_total = xmalloc (sizeof (struct descriptive_data) * cmd->n_vars); - for (v = 0 ; v < cmd->n_vars; ++v) - { - ws.dd_total[v] = dd_create (cmd->vars[v]); - } - } + for (v = 0 ; v < cmd->n_vars; ++v) + ws.dd_total[v] = dd_create (cmd->vars[v]); for (v = 0; v < cmd->n_vars; ++v) { @@ -565,11 +561,15 @@ run_oneway (const struct oneway_spec *cmd, postcalc (cmd); + for (v = 0; v < cmd->n_vars; ++v) { struct categoricals *cats = covariance_get_categoricals (ws.vws[v].cov); categoricals_done (cats); + + if (categoricals_total (cats) > ws.actual_number_of_groups) + ws.actual_number_of_groups = categoricals_total (cats); } if ( cmd->stats & STATS_HOMOGENEITY ) @@ -578,8 +578,6 @@ run_oneway (const struct oneway_spec *cmd, casereader_destroy (input); - ws.actual_number_of_groups = hsh_count (ws.group_hash); - if (!taint_has_tainted_successor (taint)) output_oneway (cmd, &ws);