bool missing_pw;
- /* Test options require that casenumbers are known */
- bool casenumbers;
-
/* The case index of the ID value (or -1) if not applicable */
size_t id_idx;
+ int id_width;
enum pc_alg pc_alg;
double *ptiles;
/* Either the casenumber or the value of the variable specified
by the /ID subcommand which corresponds to this extremity */
- double identity;
+ union value identity;
};
struct exploratory_stats
&F_8_0);
/* The casenumber */
- tab_double (t,
+ if (cmd->id_var)
+ tab_value (t,
+ heading_columns,
+ heading_rows + v * rows_per_var + i * rows_per_cat + e,
+ TAB_RIGHT,
+ &es->maxima[e].identity,
+ cmd->id_var,
+ NULL);
+ else
+ tab_double (t,
heading_columns,
- heading_rows + v * rows_per_var + i * rows_per_cat + e,
- 0,
- es->maxima[e].identity,
- &F_8_0);
-
+ heading_rows + v * rows_per_var + i * rows_per_cat + e,
+ TAB_RIGHT,
+ es->maxima[e].identity.f,
+ &F_8_0);
tab_double (t,
heading_columns + 1,
&F_8_0);
/* The casenumber */
- tab_double (t,
- heading_columns,
- heading_rows + v * rows_per_var + i * rows_per_cat + cmd->disp_extremes + e,
- 0,
- es->minima[e].identity,
- &F_8_0);
+ if (cmd->id_var)
+ tab_value (t,
+ heading_columns,
+ heading_rows + v * rows_per_var + i * rows_per_cat + cmd->disp_extremes + e,
+ TAB_RIGHT,
+ &es->minima[e].identity,
+ cmd->id_var,
+ NULL);
+ else
+ tab_double (t,
+ heading_columns,
+ heading_rows + v * rows_per_var + i * rows_per_cat + cmd->disp_extremes + e,
+ TAB_RIGHT,
+ es->minima[e].identity.f,
+ &F_8_0);
tab_double (t,
heading_columns + 1,
moments_pass_one (es[v].mom, x, weight);
- /* Save the value and the casenumber to the writer */
+ /* Save the value and the ID to the writer */
+ assert (examine->id_idx != -1);
case_data_rw_idx (outcase, EX_VAL)->f = x;
- if ( examine->id_idx != -1)
- case_data_rw_idx (outcase, EX_ID)->f = case_data_idx (c, examine->id_idx)->f;
+ value_copy (case_data_rw_idx (outcase, EX_ID),
+ case_data_idx (c, examine->id_idx), examine->id_width);
case_data_rw_idx (outcase, EX_WT)->f = weight;
es[v].maxima = pool_calloc (examine->pool, examine->calc_extremes, sizeof (*es[v].maxima));
es[v].minima = pool_calloc (examine->pool, examine->calc_extremes, sizeof (*es[v].minima));
+ for (i = 0; i < examine->calc_extremes; ++i)
+ {
+ value_init_pool (examine->pool, &es[v].maxima[i].identity, examine->id_width) ;
+ value_init_pool (examine->pool, &es[v].minima[i].identity, examine->id_width) ;
+ }
for (reader = casereader_clone (es[v].sorted_reader);
(c = casereader_read (reader)) != NULL; case_unref (c))
{
struct extremity *min = &es[v].minima[x];
min->val = val;
- min->identity = case_data_idx (c, EX_ID)->f;
+ value_copy (&min->identity, case_data_idx (c, EX_ID), examine->id_width);
}
imin += wt;
}
max = &es[v].maxima[x];
max->val = val;
- max->identity = case_data_idx (c, EX_ID)->f;
+ value_copy (&max->identity, case_data_idx (c, EX_ID), examine->id_width);
}
}
}
struct order_stats *os;
es[v].box_whisker = box_whisker_create (es[v].hinges,
- EX_ID);
+ EX_ID, examine->id_var);
os = &es[v].box_whisker->parent;
order_stats_accumulate_idx (&os, 1,
cmd->wv = dict_get_weight (cmd->dict);
- cmd->id_idx = -1;
cmd->cats
= categoricals_create (cmd->iacts, cmd->n_iacts,
cmd->wv, cmd->exclude);
categoricals_set_payload (cmd->cats, &payload, cmd, NULL);
- if (cmd->casenumbers)
+ if (cmd->id_idx == -1)
{
struct ccase *c = casereader_peek (input, 0);
- if (cmd->id_var)
- cmd->id_idx = var_get_case_index (cmd->id_var);
- else
- {
- cmd->id_idx = case_get_value_cnt (c);
- input = casereader_create_arithmetic_sequence (input, 1.0, 1.0);
- }
+ assert (cmd->id_var == NULL);
+
+ cmd->id_idx = case_get_value_cnt (c);
+ input = casereader_create_arithmetic_sequence (input, 1.0, 1.0);
case_unref (c);
}
struct examine examine;
bool percentiles_seen = false;
- examine.casenumbers = false;
examine.missing_pw = false;
examine.disp_extremes = 0;
examine.calc_extremes = 0;
examine.pc_alg = PC_HAVERAGE;
examine.ptiles = NULL;
examine.n_percentiles = 0;
- examine.id_var = 0;
+ examine.id_idx = -1;
+ examine.id_width = 0;
+ examine.id_var = NULL;
examine.boxplot_mode = BP_GROUPS;
examine.ex_proto = caseproto_create ();
- examine.ex_proto = caseproto_add_width (examine.ex_proto, 0); /* value */
- examine.ex_proto = caseproto_add_width (examine.ex_proto, 0); /* id */
- examine.ex_proto = caseproto_add_width (examine.ex_proto, 0); /* weight */
examine.pool = pool_create ();
}
}
+
if ( totals_seen && nototals_seen)
{
msg (SE, _("%s and %s are mutually exclusive"),"TOTAL","NOTOTAL");
}
- if (examine.disp_extremes > 0)
+ if ( examine.id_var )
{
- examine.calc_extremes = examine.disp_extremes;
- examine.casenumbers = true;
+ examine.id_idx = var_get_case_index (examine.id_var);
+ examine.id_width = var_get_width (examine.id_var);
}
- if (examine.boxplot)
+ examine.ex_proto = caseproto_add_width (examine.ex_proto, 0); /* value */
+ examine.ex_proto = caseproto_add_width (examine.ex_proto, examine.id_width); /* id */
+ examine.ex_proto = caseproto_add_width (examine.ex_proto, 0); /* weight */
+
+
+ if (examine.disp_extremes > 0)
{
- examine.casenumbers = true;
+ examine.calc_extremes = examine.disp_extremes;
}
-
if (examine.descriptives && examine.calc_extremes == 0)
{
/* Descriptives always displays the max and min */
#include <float.h>
#include "data/case.h"
+#include "data/data-out.h"
#include "data/val-type.h"
#include "data/variable.h"
#include "libpspp/assertion.h"
o->extreme = extreme;
ds_init_empty (&o->label);
- ds_put_format (&o->label,
- "%ld",
- (casenumber) case_data_idx (cx, bw->casenumber_idx)->f);
+ if (bw->id_var)
+ {
+ char *s = data_out (case_data_idx (cx, bw->id_idx),
+ var_get_encoding (bw->id_var),
+ var_get_print_format (bw->id_var));
+
+ ds_put_cstr (&o->label, s);
+ free (s);
+ }
+ else
+ {
+ ds_put_format (&o->label,
+ "%ld",
+ (casenumber) case_data_idx (cx, bw->id_idx)->f);
+ }
ll_push_head (&bw->outliers, &o->ll);
}
TH are the tukey hinges of the dataset.
- Casenumber_idx is the index into the casereader which will be used to label
+ id_idx is the index into the casereader which will be used to label
outliers.
+ id_var is the variable from which that label came, or NULL
*/
struct box_whisker *
box_whisker_create (const struct tukey_hinges *th,
- size_t casenumber_idx)
+ size_t id_idx, const struct variable *id_var)
{
struct box_whisker *w = xzalloc (sizeof (*w));
struct order_stats *os = &w->parent;
tukey_hinges_calculate (th, w->hinges);
- w->casenumber_idx = casenumber_idx;
+ w->id_idx = id_idx;
+ w->id_var = id_var;
w->step = (w->hinges[2] - w->hinges[0]) * 1.5;