Scripting Guide > Data Tables > Accessing Data Values > Additional Ways to Access Data Values
发布日期: 04/13/2021

Additional Ways to Access Data Values

There are other ways to specify a data table, row, and column. You can specify all three items in one expression by using an infix operator and a subscript, as follows:

dt:age[2] = 12; // table, column, and row

If you want to target multiple rows, you can use subscripts with a list or matrix of row numbers.

age[i] = 3;
age[{3, 12, 32}] = 14;
list = age[{3, 12, 32}]; // results in a list
vector = age[1 :: 20]; // results in a matrix
dt[1,1] = dt[2,1]; // in Big Class.jmp, “KATIE” (row 1, column 1) is now “LOUISE” (from row 2, column 1)
dt[0,{height}] = dt[0,{weight}]; // everybody’s height is their weight
dt[1,{height,weight}] = dt[2,4::5]; // row 1 height and weight is from Louise
dt[[5 3 1], 0] = .; /* set rows 5, 3, and 1 to missing. Using out-of-order subscripts makes more sense if the right hand side is a matrix or a data table with subscripts */

Note about Changing Values

Whenever you change values in a data table, messages are sent to the displays to keep them up-to-date. However, if you have thousands of changes in a script, this increases the time it takes to complete the updates.

In order to speed up changes, use Begin Data Update before the changes to block these update messages. Use End Data Update after the changes have been completed to release the messages and update the displays.

dt << Begin Data Update;
...<many changes>...
dt << End Data Update;

Be sure to always send the End Data Update message, otherwise the display is not updated until forced to do so in some other way.

Note: Begin Data Update does not affect the data refresh due to some other table manipulations. For example, when you delete or add columns, the data table is updated and then the data update begins.

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