Make the default view the variable view instead of the data view
[pspp] / src / language / stats / cochran.c
index 3ea8fd342b81fa45b71d78dbe03cf7200c0bbc3a..cea9a054bb2014fc25920c2ecf47e89b5796b76f 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 2010, 2011 Free Software Foundation, Inc.
+   Copyright (C) 2010, 2011, 2014 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -18,6 +18,7 @@
 
 #include "language/stats/cochran.h"
 
+#include <float.h>
 #include <gsl/gsl_cdf.h>
 #include <stdbool.h>
 
@@ -114,7 +115,7 @@ cochran_execute (const struct dataset *ds,
       rowsq += pow2 (case_hits);
     }
   casereader_destroy (input);
-  
+
   {
     double c_l = 0;
     double c_l2 = 0;
@@ -129,7 +130,7 @@ cochran_execute (const struct dataset *ds,
     ch.q *= ct->n_vars - 1;
 
     ch.q /= ct->n_vars * c_l - rowsq;
-  
+
     ch.df = ct->n_vars - 1;
   }
 
@@ -153,6 +154,7 @@ show_freqs_box (const struct one_sample_test *ost, const struct cochran *ct)
   const int column_headers = 2;
   struct tab_table *table =
     tab_create (row_headers + 2, column_headers + ost->n_vars);
+  tab_set_format (table, RC_WEIGHT, wfmt);
 
   tab_headers (table, row_headers, 0, column_headers, 0);
 
@@ -169,8 +171,10 @@ show_freqs_box (const struct one_sample_test *ost, const struct cochran *ct)
   tab_joint_text (table, 1, 0, 2, 0,
                  TAT_TITLE | TAB_CENTER, _("Value"));
 
-  tab_text_format (table, 1, 1, 0, _("Success (%g)"), ct->success);
-  tab_text_format (table, 2, 1, 0, _("Failure (%g)"), ct->failure);
+  tab_text_format (table, 1, 1, 0, _("Success (%.*g)"),
+                   DBL_DIG + 1, ct->success);
+  tab_text_format (table, 2, 1, 0, _("Failure (%.*g)"),
+                   DBL_DIG + 1, ct->failure);
 
   tab_hline (table, TAL_2, 0, tab_nc (table) - 1, column_headers);
   tab_vline (table, TAL_2, row_headers, 0, tab_nr (table) - 1);
@@ -181,10 +185,10 @@ show_freqs_box (const struct one_sample_test *ost, const struct cochran *ct)
                TAB_LEFT, var_to_string (ost->vars[i]));
 
       tab_double (table, 1, column_headers + i, 0,
-                 ct->hits[i], wfmt);
+                 ct->hits[i], NULL, RC_WEIGHT);
 
       tab_double (table, 2, column_headers + i, 0,
-                 ct->misses[i], wfmt);
+                 ct->misses[i], NULL, RC_WEIGHT);
     }
 
   tab_submit (table);
@@ -203,6 +207,9 @@ show_sig_box (const struct cochran *ch)
   struct tab_table *table =
     tab_create (row_headers + 1, column_headers + 4);
 
+
+  tab_set_format (table, RC_WEIGHT, wfmt);
+
   tab_headers (table, row_headers, 0, column_headers, 0);
 
   tab_title (table, _("Test Statistics"));
@@ -226,18 +233,18 @@ show_sig_box (const struct cochran *ch)
   tab_hline (table, TAL_2, 0, tab_nc (table) -1, column_headers);
   tab_vline (table, TAL_2, row_headers, 0, tab_nr (table) - 1);
 
-  tab_double (table, 1, column_headers, 
-             0, ch->cc, wfmt);
+  tab_double (table, 1, column_headers,
+             0, ch->cc, NULL, RC_WEIGHT);
 
-  tab_double (table, 1, column_headers + 1, 
-             0, ch->q, 0);
+  tab_double (table, 1, column_headers + 1,
+             0, ch->q, NULL, RC_OTHER);
 
-  tab_double (table, 1, column_headers + 2, 
-             0, ch->df, &F_8_0);
+  tab_double (table, 1, column_headers + 2,
+             0, ch->df, NULL, RC_INTEGER);
 
-  tab_double (table, 1, column_headers + 3, 
-             0, gsl_cdf_chisq_Q (ch->q, ch->df), 
-             0);
+  tab_double (table, 1, column_headers + 3,
+             0, gsl_cdf_chisq_Q (ch->q, ch->df),
+             NULL, RC_PVALUE);
 
   tab_submit (table);
 }