projects
/
pspp-builds.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
(parse_aggregate_functions) If dict_create_var() fails, don't
[pspp-builds.git]
/
src
/
frequencies.q
diff --git
a/src/frequencies.q
b/src/frequencies.q
index 1484776acb9b40ab4ea983d3c61eb12c2293f753..fa380dea0fef49b18a78a4b94b93da1f483a6759 100644
(file)
--- a/
src/frequencies.q
+++ b/
src/frequencies.q
@@
-279,7
+279,9
@@
static hsh_compare_func compare_freq_numeric_d, compare_freq_alpha_d;
static void do_piechart(const struct variable *var,
const struct freq_tab *frq_tab);
static void do_piechart(const struct variable *var,
const struct freq_tab *frq_tab);
-void freq_tab_to_hist(const struct freq_tab *ft, gsl_histogram *hist);
+gsl_histogram *
+freq_tab_to_hist(const struct freq_tab *ft, const struct variable *var);
+
\f
/* Parser and outline. */
\f
/* Parser and outline. */
@@
-625,20
+627,21
@@
postcalc (void *aux UNUSED)
dump_statistics (v, !dumped_freq_tab);
dump_statistics (v, !dumped_freq_tab);
+
if ( chart == GFT_HIST)
{
double d[frq_n_stats];
struct normal_curve norm;
if ( chart == GFT_HIST)
{
double d[frq_n_stats];
struct normal_curve norm;
+ gsl_histogram *hist ;
- gsl_histogram *hist = gsl_histogram_alloc(7);
- norm.N = vf->tab.
total
_cases;
+ norm.N = vf->tab.
valid
_cases;
calc_stats(v,d);
norm.mean = d[frq_mean];
norm.stddev = d[frq_stddev];
calc_stats(v,d);
norm.mean = d[frq_mean];
norm.stddev = d[frq_stddev];
-
freq_tab_to_hist(ft, hist
);
+
hist = freq_tab_to_hist(ft,v
);
histogram_plot(hist, var_to_string(v), &norm, normal);
histogram_plot(hist, var_to_string(v), &norm, normal);
@@
-652,6
+655,7
@@
postcalc (void *aux UNUSED)
}
}
+
cleanup_freq_tab (v);
}
cleanup_freq_tab (v);
}
@@
-864,7
+868,7
@@
frq_custom_grouped (struct cmd_frequencies *cmd UNUSED)
{
nl = ml = 0;
dl = NULL;
{
nl = ml = 0;
dl = NULL;
- while (
token == T_NUM
)
+ while (
lex_integer ()
)
{
if (nl >= ml)
{
{
if (nl >= ml)
{
@@
-1537,33
+1541,32
@@
dump_statistics (struct variable *v, int show_varname)
}
}
-
-/* Populate a gsl_histogram from a freq_tab */
-void
-freq_tab_to_hist(const struct freq_tab *ft, gsl_histogram *hist)
+/* Create a gsl_histogram from a freq_tab */
+gsl_histogram *
+freq_tab_to_hist(const struct freq_tab *ft, const struct variable *var)
{
int i;
double x_min = DBL_MAX;
double x_max = -DBL_MAX;
{
int i;
double x_min = DBL_MAX;
double x_max = -DBL_MAX;
-
+
+ gsl_histogram *hist;
+ const double bins = 11;
+
struct hsh_iterator hi;
struct hsh_table *fh = ft->data;
struct freq *frq;
struct hsh_iterator hi;
struct hsh_table *fh = ft->data;
struct freq *frq;
- gsl_histogram_reset(hist);
-
/* Find out the extremes of the x value */
/* Find out the extremes of the x value */
-
- for ( frq = hsh_first(fh, &hi);
- frq != 0;
- frq = hsh_next(fh, &hi) )
+ for ( frq = hsh_first(fh, &hi); frq != 0; frq = hsh_next(fh, &hi) )
{
{
+ if ( is_missing(&frq->v, var))
+ continue;
+
if ( frq->v.f < x_min ) x_min = frq->v.f ;
if ( frq->v.f > x_max ) x_max = frq->v.f ;
}
if ( frq->v.f < x_min ) x_min = frq->v.f ;
if ( frq->v.f > x_max ) x_max = frq->v.f ;
}
-
- gsl_histogram_set_ranges_uniform(hist, x_min, x_max);
+ hist = histogram_create(bins, x_min, x_max);
for( i = 0 ; i < ft->n_valid ; ++i )
{
for( i = 0 ; i < ft->n_valid ; ++i )
{
@@
-1571,8
+1574,10
@@
freq_tab_to_hist(const struct freq_tab *ft, gsl_histogram *hist)
gsl_histogram_accumulate(hist, frq->v.f, frq->c);
}
gsl_histogram_accumulate(hist, frq->v.f, frq->c);
}
+ return hist;
}
}
+
static struct slice *
freq_tab_to_slice_array(const struct freq_tab *frq_tab,
const struct variable *var,
static struct slice *
freq_tab_to_slice_array(const struct freq_tab *frq_tab,
const struct variable *var,
@@
-1602,15
+1607,14
@@
freq_tab_to_slice_array(const struct freq_tab *frq_tab,
slices[i].label = value_to_string(&frq->v, var);
slices[i].magnetude = frq->c;
slices[i].label = value_to_string(&frq->v, var);
slices[i].magnetude = frq->c;
-
}
}
-
return slices;
}
return slices;
}
+
static void
do_piechart(const struct variable *var, const struct freq_tab *frq_tab)
{
static void
do_piechart(const struct variable *var, const struct freq_tab *frq_tab)
{
@@
-1622,11
+1626,9
@@
do_piechart(const struct variable *var, const struct freq_tab *frq_tab)
piechart_plot(var_to_string(var), slices, n_slices);
free(slices);
piechart_plot(var_to_string(var), slices, n_slices);
free(slices);
-
}
}
-
/*
Local Variables:
mode: c
/*
Local Variables:
mode: c