你好,
我目前正在編寫一個腳本,以使用 Join、Transpose 和 Update 函數將三個“參考”表連接在一起。 每次我將行添加到第一個“參考”表時,我的腳本都允許更新最終輸出表。
我想知道是否可以編輯我的腳本以根據第一個“參考”表的列中的值自動對最終輸出表中的列進行分組(即“組列”函數)? 此列未包含在任何表函數中,因為它會導致轉置問題。 對於決賽桌的每次更新,這些分組保持不變是很重要的。
感謝您提供的任何反饋。
——布賴恩 D。
查看腳本索引以了解組列的使用。
這是做你所說的一種方法
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/big class.jmp" );
dt2 = New Table( "groupings",
New Column( "ID", character, set values( {"name", "age", "sex", "height", "weight"} ) ),
New Column( "Type", character, set values( {"A", "B", "C", "B", "A"} ) )
);
// Split data into columns based on Type
dtSplit = dt2 << Split( Split By( :Type ), Split( :ID ), Sort by Column Property );
// Process through the Split data table, creating the groups in the first data table
For( Group = 1, Group <= N Cols( dtSplit ), Group++,
theGroup = Column( dtSplit, Group ) << get values;
For(i=nitems(theGroup), i>=1,i--,if(theGroup[i] == "",
remove from(thegroup,i,1)));
grouping = dt << group columns( theGroup ); <BR /><BR /><FONT face="Consolas,Monaco,"Andale Mono","Ubuntu Mono",monospace" size="2" style="background-color: #f5f5f5;" color="#b00000">dt << Rename Column Group( grouping, (column(dtSplit, group)<<GET name="">
);</GET></FONT>這是你要找的東西嗎?
Names Default To Here( 1 );
dt1 = New Table( "table1", add rows(1), New Column( "test", set values( [1] ) ) );
dt2 = New Table( "table2", add rows(2),
new column( "x1", character, set values( {"a", "b"} ) ),
New Column( "x2", character, set values( {"c", "d"} ) )
);
If( dt1:test[1] == 1,
dt2 << combine columns( delimiter( "," ),
columns( dt2:x1, dt2:x2 ), Column Name( "Combined" ) )
);