/** calculates the mean of the given numeric column */ private void calcMean() { ArffSortedTableModel model; int i; double mean; // no column selected? if (m_CurrentCol == -1) return; model = (ArffSortedTableModel) m_TableArff.getModel(); // not numeric? if (!model.getAttributeAt(m_CurrentCol).isNumeric()) return; mean = 0; for (i = 0; i < model.getRowCount(); i++) mean += model.getInstances().instance(i).value(m_CurrentCol - 1); mean = mean / model.getRowCount(); // show result ComponentHelper.showMessageBox( getParent(), "Mean for attribute...", "Mean for attribute '" + m_TableArff.getPlainColumnName(m_CurrentCol) + "':\n\t" + Utils.doubleToString(mean, 3), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); }