use of edu.cmu.tetrad.data.DataModelList in project tetrad by cmu-phil.
the class SubsetContinuousVariablesAction method actionPerformed.
/**
* Performs the action of loading a session from a file.
*/
public void actionPerformed(ActionEvent e) {
DataModel selectedDataModel = getDataEditor().getSelectedDataModel();
if (selectedDataModel instanceof DataSet) {
DataSet dataSet = (DataSet) selectedDataModel;
List variables = dataSet.getVariables();
int n = 0;
for (Object variable : variables) {
if (variable instanceof ContinuousVariable) {
n++;
}
}
if (n == 0) {
JOptionPane.showMessageDialog(getDataEditor(), "There are no continuous variables in this data set.");
return;
}
int[] indices = new int[n];
int m = -1;
for (int i = 0; i < variables.size(); i++) {
if (variables.get(i) instanceof ContinuousVariable) {
indices[++m] = i;
}
}
dataSet = dataSet.subsetColumns(indices);
DataModelList list = new DataModelList();
list.add(dataSet);
getDataEditor().reset(list);
getDataEditor().selectFirstTab();
} else {
JOptionPane.showMessageDialog(JOptionUtils.centeringComp(), "Requires a tabular data set.");
}
}
Aggregations