double total; /* Grand total. */
};
-/* A crosstabulation of exactly 2 variables, conditional on zero
- or more other variables having given values. */
-struct crosstab
- {
- /* Case counts. */
- double missing;
-
- /* Variables. */
- int n_vars; /* Number of variables (at least 2). */
- const struct variable **vars;
- union value *values; /* Values of variables beyond 2. */
-
- /* Data. */
- struct table_entry **entries;
- size_t n_entries;
-
- /* Column values, number of columns. */
- union value *cols;
- int n_cols;
-
- /* Row values, number of rows. */
- union value *rows;
- int n_rows;
-
- /* Number of statistically interesting columns/rows
- (columns/rows with data in them). */
- int ns_cols, ns_rows;
-
- /* Matrix contents. */
- double *mat; /* Matrix proper. */
- double *row_tot; /* Row totals. */
- double *col_tot; /* Column totals. */
- double total; /* Grand total. */
- };
-
/* Integer mode variable info. */
struct var_range
{
struct crosstabs_proc
{
+ const struct dictionary *dict;
enum { INTEGER, GENERAL } mode;
enum mv_class exclude;
bool pivot;
init_proc (struct crosstabs_proc *proc, struct dataset *ds)
{
const struct variable *wv = dict_get_weight (dataset_dict (ds));
+ proc->dict = dataset_dict (ds);
proc->bad_warn = true;
proc->variables = NULL;
proc->n_variables = 0;
if (chisq)
{
display_dimensions (proc, &x, chisq, first_difference);
- display_chisq (pt, chisq, &showed_fisher);
+ display_chisq (&x, chisq, &showed_fisher);
}
if (sym)
{
display_dimensions (proc, &x, sym, first_difference);
- display_symmetric (proc, pt, sym);
+ display_symmetric (proc, &x, sym);
}
if (risk)
{
display_dimensions (proc, &x, risk, first_difference);
- display_risk (pt, risk);
+ display_risk (&x, risk);
}
if (direct)
{
display_dimensions (proc, &x, direct, first_difference);
- display_directional (proc, pt, direct);
+ display_directional (proc, &x, direct);
}
/* Free the parts of x that are not owned by pt. In
{
const struct variable *var = pt->const_vars[i];
size_t ofs;
+ char *s = NULL;
ds_put_format (&title, ", %s=", var_get_name (var));
/* Insert the formatted value of the variable, then trim
leading spaces in what was just inserted. */
ofs = ds_length (&title);
- data_out (&pt->const_values[i], var_get_print_format (var),
- ds_put_uninit (&title, var_get_width (var)));
+ s = data_out (&pt->const_values[i], dict_get_encoding (proc->dict), var_get_print_format (var));
+ ds_put_cstr (&title, s);
+ free (s);
ds_remove (&title, ofs, ss_cspan (ds_substr (&title, ofs, SIZE_MAX),
ss_cstr (" ")));
}
_("Exact. Sig. (2-sided)"));
tab_text (chisq, 5, 0, TAB_RIGHT | TAT_TITLE,
_("Exact. Sig. (1-sided)"));
- chisq = 0;
tab_offset (chisq, 0, 1);
return chisq;
const union value *v, const struct variable *var)
{
struct substring s;
+ char *ss;
const struct fmt_spec *print = var_get_print_format (var);
const char *label = var_lookup_value_label (var, v);
}
s.string = tab_alloc (table, print->w);
- data_out (v, print, s.string);
+ ss = data_out (v, dict_get_encoding (proc->dict), print);
+ strcpy (s.string, ss);
+ free (ss);
s.length = print->w;
if (proc->exclude == MV_NEVER && var_is_num_missing (var, v->f, MV_USER))
s.string[s.length++] = 'M';
additionally suffixed with a letter `M'. */
static void
format_cell_entry (struct tab_table *table, int c, int r, double value,
- char suffix, bool mark_missing)
+ char suffix, bool mark_missing, const struct dictionary *dict)
{
const struct fmt_spec f = {FMT_F, 10, 1};
union value v;
struct substring s;
+ char *ss;
s.length = 10;
s.string = tab_alloc (table, 16);
v.f = value;
- data_out (&v, &f, s.string);
+ ss = data_out (&v, dict_get_encoding (dict), &f);
+ strcpy (s.string, ss);
+ free (ss);
while (*s.string == ' ')
{
s.length--;
default:
NOT_REACHED ();
}
- format_cell_entry (table, c, i, v, suffix, mark_missing);
+ format_cell_entry (table, c, i, v, suffix, mark_missing, proc->dict);
}
mp++;
NOT_REACHED ();
}
- format_cell_entry (table, pt->n_cols, 0, v, suffix, mark_missing);
+ format_cell_entry (table, pt->n_cols, 0, v, suffix, mark_missing, proc->dict);
tab_next_row (table);
}
}
NOT_REACHED ();
}
- format_cell_entry (table, c, i, v, suffix, mark_missing);
+ format_cell_entry (table, c, i, v, suffix, mark_missing, proc->dict);
}
last_row = i;
}
double chisq_v[N_CHISQ];
double fisher1, fisher2;
int df[N_CHISQ];
- int s = 0;
int i;
if ((i != 2 && chisq_v[i] == SYSMIS)
|| (i == 2 && fisher1 == SYSMIS))
continue;
- s = 1;
tab_text (chisq, 0, 0, TAB_LEFT, gettext (chisq_stats[i]));
if (i != 2)