Row states change how JMP works with your data. Row States explains each row state. Remember that you can use several row states at once to get the combination of effects that you want.
If rows are excluded, JMP omits them from calculations for statistical analyses (text reports and charts). Results are the same as if the data was not entered. However, points are still included in plots. (To omit points from plots, use Hide. To omit points from all results, use both Exclude and Hide.)
|
|
If rows are hidden, JMP does not show them in plots. However, the rows are still included in text reports and charts. (To omit points from reports and charts, use Exclude. To omit points from all results, use both Exclude and Hide.)
|
|
注意:For row state messages, omitting the argument toggles the option: if the option is off, the message turns it on, and if the option is on, the message turns it off. You can also use the "toggle", "switch", or "flip" argument, as in r << Exclude( "toggle" ).
Row State Functions shows a comparison chart of the different row state functions, so that you can see which functions convert row states to numbers and numbers to row states. It also includes the numbers that you can use with each function.
Excluded(rowstate)
|
||||
Hidden(rowstate)
|
||||
Labeled(rowstate)
|
||||
Selected(rowstate)
|
||||
Marker Of(rowstate)
|
||||
Color Of(rowstate)
|
||||
To assign a row state using JSL, use Select Where to indicate which rows are affected, and then specify which row state to assign to the rows. In the following example, marker type 5 (a triangle) is assigned to rows in which sex is “F”.
3.
|
A row state column is a dedicated column that stores row state information, but does not put the information into effect. You can then use For Each Row to put the row state column into effect. For more information about row state columns, see “行状态列” in the Using JMP book.
For Each Row( Row State() = :Row State Data );
This action replaces any row states in effect with the row state combination from the row state column. For details about how to change selected attributes of a row state without changing or canceling others, see Set One Characteristic and Cancel Others.
From JSL, you can set or get row states directly using the Row State function. You can set or get the state for row n with Row State(n). If you do not supply an argument, you set or get the current row. To work with all rows, either use a For Each Row loop or work with formula columns.
Be careful whether you set every aspect of Row State() or just one aspect of it, such as Color Of( Row State() ). To see how this works, first color and mark all the rows:
For Each Row( rscol = Row State() );
Functions that take number arguments and either return states or accept state assignments all have the word “State” in their names: Row State, As Row State, Color State, Combine States, Excluded State, Hidden State, Hue State, Labeled State, Marker State, Selected State, Shade State.
Functions that take row state arguments (and assume that the argument Row State() if none is given) and functions that return or are set to numbers are either one word, or their second word is “Of”: Color Of, Excluded, Hidden, Labeled, Marker Of, Selected.
Row State Functions is a helpful comparison chart for these functions.
For Each Row( Row State() = :Row State Data );
To get a row state and store it in a global, place Row State() on the right side of an assignment. Add the following lines to the preceding script:
Show( x ); // returns x = Color State( 8 )
For Each Row( :rscol = Row State() );
You can get or set many characteristics at once by combining state settings inside Combine States(). You can also get or set each characteristic one at a time, the ultimate row state being the accumulation of characteristics. The following example sets green Y markers for males, but hides them in plots for now. It also sets red X markers for females but shows them in plots.
Notice that JMP returns a Combine State() combination. This is because a row state datum is not just the state of one characteristic, such as color, but the cumulative state of all the characteristics that have been set: exclusion, hiding, labeling, selection, markers, colors, hues, and shades. A list of such characteristics is called a row state combination.
Just as there can be many row state characteristics in effect, a row state column can have multiple characteristic row states as its values.
In addition to the overall Row State() function for getting or setting all the characteristics of a row state, there are separate functions to get or set one characteristic at a time preemptively. That is, to give a row one characteristic, canceling any other characteristics that might be in effect. The functions that set one characteristic and cancel others are as follows: Color State, Combine States, Excluded State, Hidden State, Hue State, Labeled State, Marker State, Selected State, Shade State.
A row state is not just one characteristic, but many. To work with just one characteristic at a time, use one of the L-value operators with Row State on either side of the equal sign. The side of the equal sign depends on whether you want to get or set a characteristic. There is an L-value operator for each of the following characteristics: Color Of, Excluded, Hidden, Labeled, Marker Of, Selected.
The MakeRowStateHandler message (sent to a data table object) obtains a callback when the row states change. For example,
•
|
Excluded gets or sets an excluded index. The index is 1 for true or 0 for false, indicating whether each row is excluded.
|
•
|
Hidden gets or sets a hidden index, which is 1 for hidden or 0 for not hidden.
|
•
|
Labeled gets or sets a labeled index, which is 1 for labeled or 0 for not labeled.
|
•
|
Selected gets or sets a selected index, which is 1 for selected or 0 for not selected.
|
Remember that these functions assume the argument Row State() if none is given.
Excluded State, Hidden State, Labeled State, and Selected State do the reverse; they get or set a row state condition as true or false according to the argument. Nonzero values set the row state to true, and zero values set it to false. Missing values result in no change of state.
Notice that the first two expressions above replace the row state with just the exclusion or just the unhiding, so that any preexisting row state characteristics are lost. More commonly, you would issue the state commands for all of the characteristics that you want inside a Combine States. The following example changes the third row to hidden and a green square marker:
Another common way to use a -State command would be in a row state data column whose values could be added to the row state (for cumulative characteristics). The following example excludes each odd numbered row:
Clear Row States() removes row states from the data table. The following script assigns a row state to each row and then removes the row state.
dt << Clear Row States();
To clear row states for selected rows, select the rows first and then clear the selected row states.
dt << Clear Selected Row States();
Color Of() returns or sets the color index. The color index is a number from the JMP color map that corresponds to the row state, or a missing value if there is no assigned color.
Similarly, Marker Of returns or sets the marker index. The marker index is a number from the JMP marker map that corresponds to the active marker, or a missing value if there is no assigned marker.
Both Color Of() and Marker Of() accept any row state expression or column or Row State() as arguments. They also assume the argument Row State() if none is given (some examples are shown with, and some without).
Color State() and Marker State() are similar to Color Of() and Marker Of(), except they work in the opposite direction. Where the -Of functions turn actual states into indices, the -State functions turn indices into states.
Notice that the last two commands replace the row state with just the color or just the marker, so that any preexisting row state characteristics are lost. More commonly you would issue the -State commands for all the characteristics that you want inside a Combine States(). The following example puts a green square marker in the third row and hides the row:
New Window( "Markers",
i = 0;
jj = 15;,
i < 16;
jj >= 0;,
jj--;, // 16 rows, 2 columns
图 9.13 JMP Markers
•
|
Text Color( 0 );
New Window( "Colors",
k = 0;
l = 15;
thiscolor = Color To RGB( k );
thisfill = 1;
thisfill = 0;
jj = -2;
i = 0;
图 9.14 JMP Colors
Hue State and Shade State together are an alternative to Color State for choosing colors. You cannot select black, white, or the shades of gray when you use Hue State. For these, you must use Shade State alone, or Color State.
New Window( "Hues and Shades",
k = 0;
图 9.15 Hues and Shades
There are no -Of functions for Hue and Shade. Color Of returns the equivalent Color State index for a color row state that has been set with Hue State or Shade State. For example, the following example gives rows 4 and 5 the same dark red marker:
In the following example, row state values are prepared ahead and passed to the Marker routine, along with matrices of coordinates.
Add Rows( 26 ),
dt << Run Formulas;
New Window( "CP and CA Comparisons",
Title( "CP and CA Comparison" ),