使用JSL按行和列更新數據表的一部分嗨,抱歉,我已經搜索了幾個小時,而我只是不知道該怎麼辦。 儘管我會盡力而為,但我不知道該如何提出問題,這真是令人非常惱火,現在,終於到了我身邊,這麼簡單的事情怎麼會變得如此復雜。 我發現JMP畢竟是針對某些事物的,而不是針對其他事物的。 在Python中,這對我來說非常容易。 但是我想這全都與經驗有關。 不要增加侮辱性傷害。
我希望用新數據替換我的數據表的一個子集。 我有目標行和目標列以及舊表和新數據。 這樣做的語法是什麼?
謝謝你。
麥可
數據表腳本編寫Re:使用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] = .;