- const struct variable *weight = dict_get_weight (fr->dict);
- const struct fmt_spec *wfmt = weight ? var_get_print_format (weight) : &F_8_0;
-
- const int row_headers = 1;
- const int column_headers = 0;
- struct tab_table *table =
- tab_create (row_headers + 1, column_headers + 4);
-
- tab_headers (table, row_headers, 0, column_headers, 0);
-
- tab_title (table, _("Test Statistics"));
-
- tab_text (table, 0, column_headers,
- TAT_TITLE | TAB_LEFT , _("N"));
-
- tab_text (table, 0, 1 + column_headers,
- TAT_TITLE | TAB_LEFT , _("Chi-Square"));
-
- tab_text (table, 0, 2 + column_headers,
- TAT_TITLE | TAB_LEFT, _("df"));
-
- tab_text (table, 0, 3 + column_headers,
- TAT_TITLE | TAB_LEFT, _("Asymp. Sig."));
-
- /* Box around the table */
- tab_box (table, TAL_2, TAL_2, -1, -1,
- 0, 0, tab_nc (table) - 1, tab_nr (table) - 1 );
-
-
- 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, fr->cc, wfmt);
-
- tab_double (table, 1, column_headers + 1,
- 0, fr->chi_sq, 0);
-
- tab_double (table, 1, column_headers + 2,
- 0, ost->n_vars - 1, &F_8_0);
-
- tab_double (table, 1, column_headers + 3,
- 0, gsl_cdf_chisq_Q (fr->chi_sq, ost->n_vars - 1),
- 0);
-
- tab_submit (table);
+ const struct friedman_test *ft = UP_CAST (ost, const struct friedman_test, parent);
+
+ struct pivot_table *table = pivot_table_create (N_("Test Statistics"));
+ pivot_table_set_weight_var (table, dict_get_weight (fr->dict));
+
+ struct pivot_dimension *statistics = pivot_dimension_create (
+ table, PIVOT_AXIS_ROW, N_("Statistics"),
+ N_("N"), PIVOT_RC_COUNT);
+ if (ft->kendalls_w)
+ pivot_category_create_leaves (statistics->root, N_("Kendall's W"),
+ PIVOT_RC_OTHER);
+ pivot_category_create_leaves (statistics->root,
+ N_("Chi-Square"), PIVOT_RC_OTHER,
+ N_("df"), PIVOT_RC_INTEGER,
+ N_("Asymp. Sig."), PIVOT_RC_SIGNIFICANCE);
+
+ double entries[5];
+ int n = 0;
+
+ entries[n++] = fr->cc;
+ if (ft->kendalls_w)
+ entries[n++] = fr->w;
+ entries[n++] = fr->chi_sq;
+ entries[n++] = ost->n_vars - 1;
+ entries[n++] = gsl_cdf_chisq_Q (fr->chi_sq, ost->n_vars - 1);
+ assert (n <= sizeof entries / sizeof *entries);
+
+ for (size_t i = 0; i < n; i++)
+ pivot_table_put1 (table, i, pivot_value_new_number (entries[i]));
+
+ pivot_table_submit (table);