使用JSL按行和列更新数据表的一部分嗨,抱歉,我已经搜索了几个小时,而我只是不知道该怎么办。 尽管我会尽力而为,但我不知道该如何提出问题,这真是令人非常恼火,现在,终于到了我身边,这么简单的事情怎么会变得如此复杂。 我发现JMP毕竟是针对某些事物的,而不是针对其他事物的。 在Python中,这对我来说非常容易。 但是我想这全都与经验有关。 不要增加侮辱性伤害。
我希望用新数据替换我的数据表的一个子集。 我有目标行和目标列以及旧表和新数据。 这样做的语法是什么?
谢谢你。
麦可
数据表脚本编写回复:使用JSL按行和列更新数据表的一部分这里有3种方法来更新一个表中的数据,并使用另一表中的值。
Names Default To Here( 1 );
// Open Data Table: big class.jmp
// → Data Table( "big class" )
Open( "$SAMPLE_DATA/big class.jmp" );
// Create a table with values to be input
// into the big class table
New Table( "Using Update",
New Column( "Name", character, values( {"JANE", "TIM", "ALICE"} ) ),
New Column( "Height", values( {58, 69, 64} ) ),
New Column( "Weight", values( {88, 100, 120} ) )
);
// Wait for a short time to be able to see the two
// data tables before combining them
Wait( 5 );
// Update data tables
Data Table( "big class" ) << Update( With( Data Table( "Using Update" ) ), Match Columns( :name = :Name ) );
// Update a block of data into the data table
// Create a table to get values from
New Table( "Just Data",
New Column( "A", values( {100, 101, 102, 103} ) ),
New Column( "B", values( {90, 91, 92, 93} ) )
);
// Wait for a short time to be able to see the two
// data tables before combining them
Wait( 5 );
dt = Data Table( "big class" );
dt2 = Data Table( "Just Data" );
dt[3 :: 6, 4 :: 5] = dt2[1 :: 4, 1 :: 2];
// One last simple way to move data
dt:age[2] = dt2:a[4];回复:使用 JSL 按行和列更新数据表的一部分嗨迈克尔,
我附上了一个我很久以前写的脚本来说明表操作的一些常用语法。 当您检查它时,打开您的日志以便您可以查看结果,并一次运行每一行。 如果您出现故障,它可能无法正常工作,因为有时我会做一些依赖于先前执行的代码的事情。
在您的特定情况下,您可以使用下标替换表格内容......看看这个脚本,逐行运行
names default to here(1);
//create a 10x10 table of random integers between 1 and 20
dt = As Table( J( 10, 10, Random Integer( 1, 20 ) ) );
//replace column 1 with fibonacci numbers... note 0th row means ALL rows
//note that ` is the transpose operator.
dt[0, 1] = (Round( 1 / Sqrt( 5 ) * ((1 + Sqrt( 5 )) / 2) ^ (1 :: 10) ))` ;
//replace a subbloc of the table with numbers 81-100 in a 4x5 shape
dt[3::6, 4::8] = shape(81::100, 4);
//set a subbloc to all zeros
dt[8::10, 2::4] = 0;
//store a cell's value in a variable
x = dt[2,3];
//store a subbloc in a matrix
mat = dt[4::6, 0];
//set the whole table to missing
dt[0,0] = .;