Also update all callers. Thanks to Ben for reviewing this patch.
struct variable **vars; /* Variables whose values to filter. */
size_t var_cnt; /* Number of variables. */
enum mv_class class; /* Types of missing values to filter. */
+ casenumber *n_missing;
};
static bool casereader_filter_missing_include (const struct ccase *, void *);
read or, if that never occurs, until the filtering casereader
is destroyed.
+ If N_MISSING is non-null, then after reading, it will be filled
+ with the total number of dropped cases.
+
After this function is called, READER must not ever again
be referenced directly. It will be destroyed automatically
when the filtering casereader is destroyed. */
casereader_create_filter_missing (struct casereader *reader,
const struct variable **vars, size_t var_cnt,
enum mv_class class,
+ casenumber *n_missing,
struct casewriter *exclude)
{
if (var_cnt > 0 && class != MV_NEVER)
cfm->vars = xmemdup (vars, sizeof *vars * var_cnt);
cfm->var_cnt = var_cnt;
cfm->class = class;
+ cfm->n_missing = n_missing;
+ if (n_missing) *n_missing = 0;
return casereader_create_filter_func (reader,
casereader_filter_missing_include,
casereader_filter_missing_destroy,
struct variable *var = cfm->vars[i];
const union value *value = case_data (c, var);
if (var_is_value_missing (var, value, cfm->class))
- return false;
+ {
+ if ( cfm->n_missing )
+ (*cfm->n_missing)++;
+ return false;
+ }
}
return true;
}
casereader_create_filter_missing (struct casereader *,
const struct variable **vars, size_t var_cnt,
enum mv_class,
+ casenumber *n_missing,
struct casewriter *exclude);
struct casereader *
struct hsh_table *freq_hash = NULL;
struct casereader *reader =
casereader_create_filter_missing (casereader_clone (input),
- &ost->vars[v], 1, exclude, NULL);
+ &ost->vars[v], 1, exclude,
+ NULL, NULL);
struct tab_table *freq_table =
create_variable_frequency_table(dict, reader, cst, v, &freq_hash);
double total_obs = 0.0;
struct casereader *reader =
casereader_create_filter_missing (casereader_clone (input),
- &ost->vars[v], 1, exclude, NULL);
+ &ost->vars[v], 1, exclude,
+ NULL, NULL);
struct hsh_table *freq_hash =
create_freq_hash_with_range (dict, reader,
ost->vars[v], cst->lo, cst->hi);
reader = casereader_clone (input);
reader = casereader_create_filter_missing (reader, indep_vars, n_indep,
- MV_ANY, NULL);
+ MV_ANY, NULL, NULL);
reader = casereader_create_filter_missing (reader, v_dependent, 1,
- MV_ANY, NULL);
+ MV_ANY, NULL, NULL);
n_data = data_pass_one (casereader_clone (reader),
(const struct variable **) all_vars, n_all_vars,
mom);
pass = casereader_clone (input);
pass = casereader_create_filter_missing (pass,
&v, 1,
- filter, NULL);
+ filter, NULL, NULL);
pass = casereader_create_filter_weight (pass, dict, NULL, NULL);
while (casereader_read(pass, &c))
{
input = casereader_create_filter_missing (input,
npar_specs.vv,
npar_specs.n_vars,
- npar_specs.filter, NULL);
+ npar_specs.filter,
+ NULL, NULL);
grouper = casegrouper_create_splits (input, dataset_dict (ds));
while (casegrouper_get_next_group (grouper, &group))
exclude = cmd->incl != ONEWAY_INCLUDE ? MV_ANY : MV_SYSTEM;
input = casereader_create_filter_missing (input, &indep_var, 1,
- exclude, NULL);
+ exclude, NULL, NULL);
if (cmd->miss == ONEWAY_LISTWISE)
input = casereader_create_filter_missing (input, vars, n_vars,
- exclude, NULL);
+ exclude, NULL, NULL);
input = casereader_create_filter_weight (input, dict, NULL, NULL);
reader = casereader_clone (input);
input = casereader_create_filter_missing (input, &rank_var, 1,
- exclude_values, output);
+ exclude_values, NULL, output);
input = casereader_create_filter_weight (input, dict, NULL, output);
casereader_split (input, &pass1, &pass2);
n_indep = identify_indep_vars (indep_vars, dep_var);
reader = casereader_clone (input);
reader = casereader_create_filter_missing (reader, indep_vars, n_indep,
- MV_ANY, NULL);
+ MV_ANY, NULL, NULL);
reader = casereader_create_filter_missing (reader, &dep_var, 1,
- MV_ANY, NULL);
+ MV_ANY, NULL, NULL);
n_data = prepare_categories (casereader_clone (reader),
indep_vars, n_indep, mom);
input = casereader_create_filter_missing (input,
cmd->v_variables,
cmd->n_variables,
- exclude, NULL);
+ exclude, NULL, NULL);
input = casereader_create_filter_weight (input, dict, NULL, NULL);