发布日期: 11/15/2021

Add Rows

To add rows, send an Add Rows message and specify how many rows. You can also specify after which row to insert the new rows. The arguments can either be numbers or expressions that evaluate to numbers.

dt << Add Rows( 3 ); // add 3 rows to bottom of data table
dt << Add Rows( 3, 10 ); /* add 3 rows after the 10th row, moving the 11th and lower rows farther down */

A variation of Add Rows lets you specify an argument yielding a list of assignments. Assignments can be separated with commas or semicolons.

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << Add Rows(
	{:name = "Peter", :age = 14, :sex = "M", :height = 61, :weight = 124}
);

or

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << Add Rows(
	{:name = "Peter"; :age = 14; :sex = "M"; :height = 61; :weight = 124}
);

You can send several arguments yielding lists, or even a list of lists. The following script creates a data table with Add Rows commands of each variety:

dt = New Table( "Cities" );
dt << New Column( "xx", Numeric );
dt << New Column( "cc", Character, width( 12 ) );
 
dt << Add Rows( {xx = 12, cc = "Chicago"} ); // single list
dt << Add Rows( // several lists
	{xx = 13, cc = "New York"}, {xx = 14, cc = "Newark"} );
dt << Add Rows( // list of lists
	{{xx = 15, cc = "San Francisco"}, {xx = Sqrt( 256 ), cc = "Oakland"}}
);
a = {xx = 20, cc = "Miami"};
dt << Add Rows( a ); // evaluate as single list
 
b={{xx = 17, cc = "San Antonio"},{xx = 18, cc = "Houston"}, {xx = 19, cc = "Dallas"}};
dt << Add Rows( b ); // evaluate as list of lists

Further information for rows can be specified with messages described under Row States.

需要更多信息?有问题?从 JMP 用户社区得到解答 (community.jmp.com).