该帮助的版本不再更新,请参见https://www.jmp.com/support/help/zh-cn/15.2 获取最新的版本.


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 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”.
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << Select Where( :sex == "F" ) << Markers( 5 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << New Column( "Row State",
Set Formula( If( :sex == "F", Marker State( 4 ) ) )
Column( "Row State" ) << Copy To Row States();
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.
dt = New Table( "Row State Testing" );
dt << New Column( "Row State Data", Row State, Set Formula( Color State( Row() ) ) );
dt << Add Rows( 10 );
For Each Row( Row State() = :Row State Data );
图 9.12 Table with No Row States (left) and Table with Row States (right)
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.
dt1 = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt2 = Open( "$SAMPLE_DATA/San Francisco Crime.jmp" );
Row State( dt1, 1 ) = Color State( 3 ); // make row 1 red;
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:
dt1 = Open( "$SAMPLE_DATA/Big Class.jmp" );
Row State() = Combine States( Color State( Row() ), Marker State( Row() ) ) );
Color Of( Row State( 1 ) ) = 3; // make row 1 red without changing marker
Row State( 1 ) = Color State( 5 ); // make row 1 blue and removes its marker
New Column( "rscol", Set Formula( Row State() ) );
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.
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << New Column( "Row State Data", Row State, Set Formula( Color State( Row() ) ) );
dt << Add Rows( 10 );
For Each Row( Row State() = :Row State Data );
Row State( 1 ); // returns row state for row 1
Row() = 8; Row State(); // returns row state for current (8th) row
For Each Row( Print( Row State()) ); // returns the row states for each row
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:
::x = Row State( 1 ); // put the row state of row 1 in x, a global
Row() = 8; ::x = Row State(); // put the row state of the 8th row in x
Show( x ); // returns x = Color State( 8 )
dt << New Column( "rscol", Row State) ;
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.
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
If( sex == "M",
/* then */ Row State() = Combine States(
Color State( 4 ), Marker State( 6 ), Hidden State( 1 ) ),
/* else */ Row State() = Combine States(
Color State( 3 ), Marker State( 2 ), Hidden State( 0 ) ) ) );
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.
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:
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
Row State( 3 ) = Combine States(
Color State( 4 ),
Marker State( 3 ),
Hidden State( 1 ) );
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:
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << New Column( "myExcl",
Set Formula( Excluded State( Modulo( Row(), 2 ) ) )
For Each Row( Row State() = Combine States( :myExcl, Row State() ) );
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 = Open( "$SAMPLE_DATA/Big Class.jmp" );
For Each Row( Row State() = Color State( Row() ) );
Wait( 3 ); // pause for demonstration purposes
dt << Clear Row States();
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
For Each Row( Row State() = Color State( Row() ) );
dt << Select Rows( [ 5 ] );
Wait( 3 ); // pause for demonstration purposes
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:
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
Row State( 3 ) = Combine States(
Color State( 4 ),
Marker State( 3 ),
Hidden State( 1 ) );
New Window( "Markers",
Graph Box(
FrameSize( 300, 300 ),
Y Scale( -1, 16 ),
X Scale( 0, 7 ),
For(
jj = 15;,
jj--;, // 16 rows, 2 columns
Marker Size( 3 );
Marker( i, {1, jj + .2} ); // markers 0-15
Marker( i + 16, {4, jj + .2} ); // markers 16-31
Text( {1.5, jj}, "marker ", i ); // marker labels 0-15
Text( {4.5, jj}, "marker ", i + 16 ); // marker labels 16-31
图 9.13 JMP Markers
New Window( "Colors",
FrameSize( 640, 400 ),
Y Scale( -1, 17 ),
X Scale( -3, 12 ),
For( jj = 1, jj <= 12, jj += 2,
For( i = 0, i <= 15 & k < 85, i++,
thiscolor = Color To RGB( k );
Fill Color( k );
Pen Color( 0 );
Pen Color( k )
Rect( jj, l + .5, jj + .5, l, thisfill );
Text( {jj - 1, l}, "color ", k );
color = {"Black", "Gray", "White", "Red", "Green", "Blue", "Orange", "BlueGreen",
"Purple", "Yellow", "Cyan", "Magenta", "YellowGreen", "BlueCyan", "Fuschia", "Black"};
For(
l = 15;, i <= 15 & l >= 0,
Text( {jj, l}, color[i + 1] )
图 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",
Graph Box(
FrameSize( 600, 300 ),
Y Scale( -3, 3 ),
X Scale( -2, 12 ),
For( h = 0, h < 12, h++,
For( s = -2, s < 3, s++,
myMk = Combine States( Hue State( h ), Shade State( s ), Marker State( 15 ) );
Marker Size( 3 );
Marker( myMk, {h, s} );
Text( Center Justified, {5, 2.5}, " <--- Hues 0-11 ---> " );
Text( Right Justified,
{-.5, -2}, "Shade -2", {-.5, -2.25}, "(Very dark)",
{-.5, -1}, "Shade -1", {-.5, -1.25}, "(Dark)",
{-.5, 0}, "Shade 0", {-.5, -.25}, "(Basic hue)",
{-.5, 1}, "Shade 1", {-.5, .75}, "(Light)",
{-.5, 2}, "Shade 2", {-.5, 1.75}, "(Very light)"
图 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:
dt = New Table( "Artificial CP and CA data",
New Column( "cover_cp",
"Continuous",
Formula( Random Uniform() / 100 + 0.94 )
New Column( "cover_ca",
"Continuous",
Formula( Random Uniform() * 0.04 + 0.94 )
New Column( "p", Numeric, "Continuous", Formula( Random Uniform() ) )
dt << Run Formulas;
greenMark = Combine States( Marker State( 2 ), Color State( 4 ) );
redDiamond = Combine States( Marker State( 3 ), Color State( 3 ) );
New Window( "CP and CA Comparisons",
Graph Box(
Title( "CP and CA Comparison" ),
FrameSize( 400, 350 ),
X Scale( 0, 1 ),
Y Scale( 0.94, 1 ),
For Each Row(
Marker( greenMark, {p, cover_cp} );
Marker( redDiamond, {p, cover_ca} );
图 9.16 Example of Row States Values and Matrices