使用 JSL 按行和列更新数据表的一部分嗨,抱歉,我已经在谷歌上搜索了几个小时了,但我不知道该怎么办。 我不知道如何提出我的问题,尽管我会尽我最大的努力,这真的很令人恼火,现在终于让我明白,这么简单的事情怎么会如此复杂。 毕竟,我发现 JMP 是用于某些用途而不是其他用途。 在 Python 中,这对我来说非常容易。 但我想这全都取决于经验。 不是为了雪上加霜。
我希望用新数据替换数据表的子集。 我有目标行和目标列以及旧表和新数据。 执行此操作的语法是什么?
谢谢。
迈克尔
高级统计建模自动化和脚本编写消费者和市场研究数据存取数据混合和清理大规模定制回复:使用 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] = .;
回复:使用 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];