class CrossTab {

  private static Table rowPercents(Table xTabCounts) {

    Table pctTable = Table.create("Crosstab Row Proportions: ");
    StringColumn labels = StringColumn.create(LABEL_COLUMN_NAME);

    pctTable.addColumns(labels);

    for (int i = 0; i < xTabCounts.rowCount(); i++) {
      labels.append(xTabCounts.column(0).getString(i));
    }

    // create the new cols
    DoubleColumn[] newColumns = new DoubleColumn[xTabCounts.columnCount() - 1];

    for (int i = 1; i < xTabCounts.columnCount(); i++) {
      Column<?> column = xTabCounts.column(i);
      newColumns[i - 1] = DoubleColumn.create(column.name());
    }

    for (int i = 0; i < xTabCounts.rowCount(); i++) {
      double rowTotal = xTabCounts.numberColumn(xTabCounts.columnCount() - 1).getDouble(i);

      for (int c = 0; c < newColumns.length; c++) {
        if (rowTotal == 0) {
          newColumns[c].append(Double.NaN);
        } else {
          newColumns[c].append(xTabCounts.numberColumn(c + 1).getDouble(i) / rowTotal);
        }
      }
    }
    pctTable.addColumns(newColumns);
    return pctTable;
  }

  private  CrossTab();

}