size_t n;
size_t allocated;
- struct variable *scale_var;
+ struct variable *var;
};
static void ctables_summary_spec_set_clone (struct ctables_summary_spec_set *,
.specs = specs,
.n = src->n,
.allocated = src->n,
- .scale_var = src->scale_var
+ .var = src->var
};
}
assert (n == allocate);
const struct ctables_nest *summary_src;
- if (!a->specs[CSV_CELL].n && !a->specs[CSV_CELL].scale_var)
+ if (!a->specs[CSV_CELL].var)
summary_src = b;
- else if (!b->specs[CSV_CELL].n && !b->specs[CSV_CELL].scale_var)
+ else if (!b->specs[CSV_CELL].var)
summary_src = a;
else
NOT_REACHED ();
for (enum ctables_summary_variant sv = 0; sv < N_CSVS; sv++)
{
ctables_summary_spec_set_clone (&nest->specs[sv], &a->specs[sv]);
- nest->specs[sv].scale_var = a->var.var;
+ nest->specs[sv].var = a->var.var;
}
return (struct ctables_stack) { .nests = nest, .n = 1 };
static void
ctables_summary_add (union ctables_summary *s,
const struct ctables_summary_spec *ss,
- const struct variable *scale_var, const union value *value,
+ const struct variable *var, const union value *value,
double d_weight, double e_weight)
{
/* To determine whether a case is included in a given table for a particular
switch (ss->function)
{
case CTSF_COUNT:
-
case CSTF_TOTALN:
case CTSF_VALIDN:
- if (scale_var && var_is_value_missing (scale_var, value))
+ if (var_is_value_missing (var, value))
s->missing += d_weight;
else
s->valid += d_weight;
case CTSF_MISSING:
case CTSF_ETOTALN:
case CTSF_EVALIDN:
- if (scale_var && var_is_value_missing (scale_var, value))
+ if (var_is_value_missing (var, value))
s->missing += e_weight;
else
s->valid += e_weight;
case CTSF_MAXIMUM:
case CTSF_MINIMUM:
case CTSF_RANGE:
- if (!var_is_value_missing (scale_var, value))
+ if (!var_is_value_missing (var, value))
{
- assert (!var_is_alpha (scale_var)); /* XXX? */
+ assert (!var_is_alpha (var)); /* XXX? */
if (s->min == SYSMIS || value->f < s->min)
s->min = value->f;
if (s->max == SYSMIS || value->f > s->max)
case CTSF_LAYERPCT_SUM:
case CTSF_LAYERROWPCT_SUM:
case CTSF_LAYERCOLPCT_SUM:
- if (!var_is_value_missing (scale_var, value))
+ if (!var_is_value_missing (var, value))
moments1_add (s->moments, value->f, e_weight);
break;
case CTSF_MEDIAN:
case CTSF_MODE:
case CTSF_PTILE:
- if (var_is_value_missing (scale_var, value))
+ if (var_is_value_missing (var, value))
{
s->ovalid += e_weight;
const struct ctables_summary_spec_set *specs = &ss->specs[cell->sv];
for (size_t i = 0; i < specs->n; i++)
- {
- const struct variable *scale_var = specs->scale_var;
- const union value *value = scale_var ? case_data (c, scale_var) : NULL;
- ctables_summary_add (&cell->summaries[i], &specs->specs[i],
- scale_var, value, d_weight, e_weight);
- }
+ ctables_summary_add (&cell->summaries[i], &specs->specs[i], specs->var,
+ case_data (c, specs->var), d_weight, e_weight);
if (cell->contributes_to_domains)
{
for (enum ctables_domain_type dt = 0; dt < N_CTDTS; dt++)
specs->n = 1;
enum ctables_summary_function function
- = specs->scale_var ? CTSF_MEAN : CTSF_COUNT;
- struct ctables_var var = { .var = specs->scale_var };
+ = specs->var ? CTSF_MEAN : CTSF_COUNT;
+ struct ctables_var var = { .is_mrset = false, .var = specs->var };
*specs->specs = (struct ctables_summary_spec) {
.function = function,
.format = ctables_summary_default_format (function, &var),
.label = ctables_summary_default_label (function, 0),
};
+ if (!specs->var)
+ specs->var = nest->vars[0];
ctables_summary_spec_set_clone (&nest->specs[CSV_TOTAL],
&nest->specs[CSV_CELL]);