MEANS: Fix output with unusual formats
authorJohn Darrington <john@darrington.wattle.id.au>
Sun, 23 Jun 2019 16:49:47 +0000 (18:49 +0200)
committerJohn Darrington <john@darrington.wattle.id.au>
Sun, 23 Jun 2019 16:49:47 +0000 (18:49 +0200)
src/language/stats/means-calc.c
src/language/stats/means.c
tests/language/stats/means.at

index 5a3c205b97788d3672c09d238e68ab8058d597d3..54b4e9cce52bddfe3dd556b178dd3a0abe6f62d4 100644 (file)
@@ -435,11 +435,11 @@ const struct cell_spec cell_spec[n_MEANS_STATISTICS] = {
   {N_("Minimum"),        "MIN",       NULL          ,   min_create,       min_update,       min_get,       simple_destroy},
   {N_("Maximum"),        "MAX",       NULL          ,   max_create,       max_update,       max_get,       simple_destroy},
   {N_("Range"),          "RANGE",     NULL          ,   range_create,     range_update,     range_get,     simple_destroy},
-  {N_("Variance"),       "VARIANCE",  NULL          ,   default_create,   default_update,   variance_get,  default_destroy},
-  {N_("Kurtosis"),       "KURT",      NULL          ,   default_create,   default_update,   kurt_get,      default_destroy},
-  {N_("S.E. Kurt"),      "SEKURT",    NULL          ,   default_create,   default_update,   sekurt_get,    default_destroy},
-  {N_("Skewness"),       "SKEW",      NULL          ,   default_create,   default_update,   skew_get,      default_destroy},
-  {N_("S.E. Skew"),      "SESKEW",    NULL          ,   default_create,   default_update,   seskew_get,    default_destroy},
+  {N_("Variance"),       "VARIANCE",  PIVOT_RC_OTHER,   default_create,   default_update,   variance_get,  default_destroy},
+  {N_("Kurtosis"),       "KURT",      PIVOT_RC_OTHER,   default_create,   default_update,   kurt_get,      default_destroy},
+  {N_("S.E. Kurt"),      "SEKURT",    PIVOT_RC_OTHER,   default_create,   default_update,   sekurt_get,    default_destroy},
+  {N_("Skewness"),       "SKEW",      PIVOT_RC_OTHER,   default_create,   default_update,   skew_get,      default_destroy},
+  {N_("S.E. Skew"),      "SESKEW",    PIVOT_RC_OTHER,   default_create,   default_update,   seskew_get,    default_destroy},
   {N_("First"),          "FIRST",     NULL          ,   first_create,     first_update,     first_get,     simple_destroy},
   {N_("Last"),           "LAST",      NULL          ,   last_create,      last_update,      last_get,      simple_destroy},
 #if 0
index 94ee1d1956409c276587865c79c9e0ebb522081a..40ee4a9035eb14e192e62dd9411f4c9178d737ca 100644 (file)
@@ -775,18 +775,17 @@ means_shipout_multivar (const struct mtable *mt, const struct means *means,
   ds_init_empty (&dss);
   for (int dv = 0; dv < mt->n_dep_vars; ++dv)
     {
-      ds_put_cstr (&dss, var_get_name (mt->dep_vars[dv]));
-      if (mt->n_layers > 0)
+      if (dv > 0)
        ds_put_cstr (&dss, " * ");
+      ds_put_cstr (&dss, var_get_name (mt->dep_vars[dv]));
     }
 
   for (int l = 0; l < mt->n_layers; ++l)
     {
+      ds_put_cstr (&dss, " * ");
       const struct layer *layer = mt->layers[l];
       const struct variable *var = layer->factor_vars[ws->control_idx[l]];
       ds_put_cstr (&dss, var_get_name (var));
-      if (l < mt->n_layers - 1)
-       ds_put_cstr (&dss, " * ");
     }
 
   struct pivot_table *pt = pivot_table_create (ds_cstr (&dss));
index 8e48319d704a06fa1f003ad9e2147c9841a80b22..eda5fef177a67ad5020a6d54097ed518d19b9c13 100644 (file)
@@ -1087,4 +1087,38 @@ N,Mean
 AT_CLEANUP
 
 
+dnl Test the output with unusual dependent variable formats
+AT_SETUP([MEANS formats])
+AT_KEYWORDS([categorical categoricals])
+
+AT_DATA([means-formats.sps], [dnl
+data list notable list /hours (TIME11.0) rate (DOLLAR8.2).
+begin data
+12:00 4.09
+14:01 5.23
+end data.
+
+means hours rate
+ /cells = mean count max range.
+])
+
+AT_CHECK([pspp -O format=csv means-formats.sps], [0], [dnl
+Table: Case Processing Summary
+,Cases,,,,,
+,Included,,Excluded,,Total,
+,N,Percent,N,Percent,N,Percent
+hours,2,100.0%,0,.0%,2,100.0%
+rate,2,100.0%,0,.0%,2,100.0%
+
+Table: hours * rate
+,hours,rate
+Mean,13:00:30,$4.66
+N,2,2
+Maximum,14:01:00,$5.23
+Range,02:01:00,$1.14
+])
+
+AT_CLEANUP
+
+