Edit Classifiers

Classifier variables are normally imported from text files produced by spreadsheet or database programs or extracted from the identifier variable. Sometimes, it is necessary to make additional changes, such as correcting inconsistencies in spelling (e.g., all comparisions of classifier values in MorphoJ aere case-sensitive) or combining multiple classifiers into one.

MorphoJ offers a number of possibilities for editing the classifier variables to make such changes. You can change individual entries of classifiers, replace occurrences of certain values of a classifier, or copy and paste to or from MS Excel spreadsheets (or similar programs). You can also add or delete entire classifier variables, change their names, or combine the values of two or more classifiers into a new, single classifier.

To do this, select the dataset by clicking on its icon in the Project Tree window, and then select Edit Classifiers from the Preliminaries menu. A user interface like the following will appear:

Most of the user interface is taken up by a spreadsheet-style table that shows the classifier variables in its columns and the observations as rows. The table can be used for inspecting and editing individual values of the classifier variables.

Below the table are several other controls for selecting and manipulating classifier variables. Several tasks can be performed that will either change the values of the classifier variables or the variables themselves.

All the manipulations of the table are carried out on a copy of the classifiers in the dataset. By clicking Cancel, the procedure can be aborted and the dataset thus keeps its previous state. By clicking Accept, all the changes made are transferred to the dataset and made permanent. Moreover, other datasets or analyses that depend on the classifiers in the dataset are updated to reflect the changes. In particular, if classifiers are deleted from the dataset, some other analyses and relevant datasets that relate to these classifiers may need to be deleted (in this case, a warning is given to the user before the classifiers are deleted from the copy).

Changing the values of classifier variables

Editing individual classifier values

Individual values of classifiers can be edited by double-clicking on the respective cell of the table. This opens a drop-down menu with all the values currently represented in the column for this classifier variable, such as this example for the column "food" in the screen shot above:

The values of the classifier are "carnivore", "herbivore" and "omnivore" and also the empty string "" for the entries with no information. Any of theses values can be selected from the drop-down menu. Using the drop-down menu is preferable because it both faster than typing the values and also is less likely to produce errors such as inconsistent spelling or use of upper- and lower-case letters.

If a new value is needed, it can be typed into the text box in the table cell. After typing the value, press the Enter or Return button of the keyboard to indicate that the entry is complete. This value is then available in the drop-down menus for all the cells in the same column of the table.

Finding and replacing values of classifiers

For changing entire series of values of a classifier variable, select the variable by clicking on its name in the header bar of the table or in the list of classifiers at the lower-left corner of the interface. Then click on the Replace values button. A dialog box like the following will appear:

The two drop-down menus are for selecting the value to be replaced (upper menu) and the value to be inserted instead (lower menu). For the latter, it is also possible to type in a new value.

To replace single occurrences of a value, use the Find Next and Replace buttons to navigate to an appropriate occurrence and to make the replacement. (After using the Replace button, the selection does not automatically advance to the next occurrence, so that the user can check the effect of the change.)

Alternatively, use Replace All to replace all occurrences of a given value. This is particularly convenient to make the values of a classifier consistent. For instance, if a classifier for sex has the values "female", "male" and "Male", it is easy to change all occurrences of "Male" into "male" to make the values consistent.

Clicking the Done button closes the dialog box.

Copying and pasting

A further way to change the values of classifier variables is to paste values from spreadsheet programs like MS Excel. To to copy values from this table to such programs. This can be done with the usual Copy/Paste commands of the operating system (e.g., for Windows, by typing control-C for copying and control-V for pasting).

To select ranges of cells for copying and pasting, these must be selected in the body of the table itself. Selecting columns by clicking on the table's header bar or by selecting classifiers in the list in the lower-left part of the interface will yield copies of the classifier names, not the values for the observations.

Changing classifier variables

Changing the name of a classifier variable

To change the name of a classifier variable, first select its current name in the header bar of the table or in the list in the lower-left part of the user interface. The name of the variable will then also appear in the text field in the lower-right part of the user interface, where the user can replace it with a new name. Clicking the Rename classifier button will then make the name change.

Adding a classifier variable

To add a new classifier variable, click the Add classifier button. The following dialog box will then appear:

Enter a name for the new classifier variable and click OK to create the new variable. It is added at the end of the list of variables. There are no values associated with this variable, but these need to be set by one of the methods outlined above for editing individual classifier values.

If the values for the new classifier already exist in an external program (e.g. spreadsheet, data base), it is probably easier to import the classifier from a text file.

Deleting classifier variables

To delete one or more classifier variables, select the names of the variables and click Delete classifier(s).

If none of the selected classifiers is in use by an analysis in the project, the variable or variables will be deleted. Note that this cannot be undone, but clicking Cancel will prevent the deletion from becoming permanent (but will also discard any other changes made to the classifiers).

If one or more of the classifiers are used by analyses in the project, a dialog box like the following will appear:

The warning in this dialog box indicates that a canonical variate analysis named "CVA food & habitat" and the dataset "CVA food & habitat, scores" are affected because the CVA is using the classifier that was chosen for deletion. If the classifier is deleted, the analysis and the dataset with the CVA scores will also be deleted. If the user clicks OK, the classifier will be deleted along with any analyses and datasets that depend on it. Clicking Cancel aborts the process.

Any deletions, both of the classifiers and of the analyses or datasets that depend on them, can still be discarded by aborting the process of editing classifiers (click the Cancel button in the user interface for editing classifiers). All these changes are only made irreversible when the Accept button is clicked.

Combining classifier variables

Two or more classifiers can be combined into a new one, so that the values of the new classifier convey the combined information of all original classifiers. For instance, information about diet (herbivore, carnivore) and habitat (terrestrial, aquatic) can be combined so that a new classifier would specify whether a species is, for instance, an aquatic herbivore or a terrestrial carnivore.

To start the procedure, select the names of the variables that are to be combined in the list in the lower-left corner of the user interface. Then click on the Combine classifiers button. The following dialog box will appear:

Enter a name for the new classifier and click the OK button to proceed or click Cancel to stop.

Copying a classifier variable

There is no special button for copying a classifier, but it is possible to obtain a copy of a classifier under a new name by using the Combine classifiers button while only a single classifier is selected.