忽略「排除」行你好,
我仍在努力克服 JSL“駝峰”,所以請原諒這個基本問題。
問題:
- 我有一個樣本表,其中包含三個重複的資料集,樣本後綴為 a1、a2 和 a3。
- 有時,需要將其中一個重複設定為「排除」狀態(下面的範例是 a2)
- 我正在編寫一個批次腳本,它將打開一個表並僅應用未排除的集合的計算。
- 然而,我仍然沒有進行我的嘗試(如下所示),因為來自所有三個的數據仍在考慮中。
- 我覺得可能需要使用“and”語句來識別非排除行,然後應用後綴搜尋。
任何意見,將不勝感激。
謝謝尼爾
states = Current Data Table() << Get Row States();
For( i = 1, i <= N Rows( states ), i++,
rs = As Row State( states[i] );
if (Excluded(rs)==0,
a1 = dt << Get Rows Where(Contains(:Sample,"a1"));
a2 = dt << Get Rows Where(Contains(:Sample,"a2"));
a3 = dt << Get Rows Where(Contains(:Sample,"a3"));
);
)
品質和工藝工程回覆:忽略「排除」行一定要看看 tabulate 平台和 summarise JSL 函數,我認為兩者都可以很快得到答案。
回覆:忽略「排除」行非常感謝!
我會嘗試一下,看看效果如何。
最初的目的只是取得每組(a1、a2 和 a3)的一行的孔隙率並取得平均值。 每個重複的孔隙率是相同的,但無法找到更簡單的方法來提取 3 個不同的點並求平均值。
再次感謝您的意見。
尼爾
回覆:忽略「排除」行這是一個更新的腳本,它遍歷虹膜資料表中的每個物種,並計算符合該條件的行的平均值。也就是說,既然我更了解你在做什麼,我可能會以不同的方式處理這個問題,並使用 tabulate 來尋找這些值。
Names default to here(1);
//Make a sample dataset with some excluded rows
dt = Open("$Sample_data/iris.jmp");
excluded rows to set = [ 4, 9, 52 ];
dt << Select Rows( excluded rows to set );
dt << Exclude(1);
species list = {"setosa", "versicolor", "virginica"};
//For each species
for(s=1, s<= n items (species list), s++,
//Find all matching rows and load in associative array, useful for Remove From function later
species matches = associative array(dt << Get Rows Where(:Species == species list[s]));
//get excluded rows
excluded rows = dt << get excluded rows();
//remove excluded rows from the list of rows matching the species
Remove From (species matches, excluded rows);
//get the matching rows as a list, use that to find which rows to average
mn = mean( :Sepal length[speciesmatches << get keys] );
//output averages to the log
write(species list[s] || " mean = " || char(mn) || "\!n")
);
使用表格的選項:
Names default to here(1);
//Make a sample dataset with some excluded rows
dt = Open("$Sample_data/iris.jmp");
excluded rows to set = [ 4, 9, 52 ];
dt << Select Rows( excluded rows to set );
dt << Exclude(1);
//New column with the check for each value
New Column("Species_", Character, "Nominal", Formula(If(Contains(:Species, "se"), "se", Contains(:Species, "ve"), "ve", Contains(:Species, "vi"), "vi")));
//tabulate to find averages - script copied from 'source' of data table after selecting
//'make into data table' from tabulate platform, then inserted dt reference
dtTab = (dt << Tabulate(
Set Format( Mean( :Sepal length( 10, 4 ) ) ),
Add Table(
Column Table( Analysis Columns( :Sepal length ), Statistics( Mean ) ),
Row Table( Grouping Columns( :Species_ ) )
)
)) << Make Into Data Table;
//Now get values from the table
dtTab:"Mean(Sepal length)"n[dtTab << Get Rows Where(:Species_ == "se")];回覆:忽略「排除」行呃,
非常感謝您的意見。 我還是個新手,但嘗試了一下關聯數組的概念。 顯示代碼並將一直工作到“獲取密鑰”。 但是,我仍然不確定如何從“speciesmatches”中獲取所需的資訊來進行所需的計算(列出最後 6 行)。 我拍攝了一張包含排除集的典型表格的圖像。
尼爾
dt = Open( path );
// Find row that were excluded and load into list
Exc_row = dt << Get Excluded Rows;
dt << Select Rows( Exc_row );
dt << Exclude(1);
//Find all matching rows and load in associative array, useful for Remove From function later
species matches = associative array(dt << Get Rows Where(Contains(:Sample,"a1") |Contains(:Sample,"a2") |Contains(:Sample,"a3")));
//get excluded rows
Exc_row = dt << get excluded rows();
//remove excluded rows from the list of rows matching the species
Remove From (species matches, Exc_row);
//get the matching rows as a list
speciesmatches << get keys;
// What needs to be done to get mean of three (or 2 sets in the case of exclusion see table image)
a1 = dt << Get Rows Where(Contains(:Sample,"a1"));
a2 = dt << Get Rows Where(Contains(:Sample,"a2"));
a3 = dt << Get Rows Where(Contains(:Sample,"a3"));<BR />
c1 = Column("Image A pore area (%)");
mean1 = Mean(c1[a1[1]], c1[a2[1]], c1[a3[1]]);
回覆:忽略「排除」行看起來您正在迭代排除行的列表,但每次都進行相同的分析,這實際上並沒有在任何地方引用排除行的列表。這是可能解決您的問題的一種方法,它會取得匹配的行和排除的行,然後從清單中刪除排除的行。
Names default to here(1);
//Make a sample dataset with some excluded rows
dt = Open("$Sample_data/iris.jmp");
excluded rows to set = [ 4, 9, 52 ];
dt << Select Rows( excluded rows to set );
dt << Exclude(1);
//Find all matching rows and load in associative array, useful for Remove From function later
species matches = associative array(dt << Get Rows Where(:Species == "setosa"));
//get excluded rows
excluded rows = dt << get excluded rows();
//remove excluded rows from the list of rows matching the species
Remove From (species matches, excluded rows);
//get the matching rows as a list
speciesmatches << get keys;