使用 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];