大家好,
我正在嘗試集成 jmp 以便將乙醇發酵數據處理成圖表和其他指標。 我在將現有數據格式轉換為 JMP 可用的表格時遇到了一些問題。
我們以穀歌表格的形式從工廠接收數據。 我可以將此數據表上傳到 JMP。 問題在於數據的格式。 數據按每行的批號列出,每列是一串帶有數字的文本,例如“4hr Ethanol”或“8hr Lactic”。 請參閱下面的示例。
| 批 | 0hr 乙醇 | 0 小時乳酸 | 0 小時醋酸 | 4小時乙醇 | 4小時乳酸 | 4小時醋酸 | …… | 60 小時乙醇 | 60 小時乳酸 | 60 小時醋酸 |
| 1 | | | | | | | | | | |
| 2 | | | | | | | | | | |
| 3 | | | | | | | | | | |
| 4 | | | | | | | | | | |
我需要按時間劃分每個類別。 例如,我想繪製第 2 批和第 3 批從 0 到 60 小時的乙醇濃度。 我相信我需要將數據表、文本堆疊到列中,並使用 recode 將列標題從文本字符串更改為以小時為單位的時間作為數字條目。 我在獲取表格時遇到了一些問題,我希望它如何創建這些圖表。 任何幫助,將不勝感激。 提前致謝。
這是一個使用虛構數據生成乙醇圖表的示例

這是一個產生情節的腳本
Names Default To Here( 1 );
// Create a sample data table
dt = New Table( "Example",
Add Rows( 4 ),
New Column( "Batch", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [1, 2, 3, 4] ) ),
New Column( "0hr Ethanol",
Numeric,
"Nominal",
Format( "", 16 ),
Set Values( [103.347990080313, 90.8056789034286, 110.847323879326, 94.4892596023655] )
),
New Column( "0 hr Lactic",
Numeric,
"Nominal",
Format( "", 16 ),
Set Selected,
Set Values( [98.2941757953967, 87.0280094785425, 96.8477348247328, 92.910237668013] )
),
New Column( "0 hr Acetic",
Numeric,
"Nominal",
Format( "", 16 ),
Set Values( [86.0736604847805, 84.7654940657705, 103.653020778599, 103.896496570196] )
),
New Column( "4hr Ethanol",
Numeric,
"Nominal",
Format( "", 16 ),
Set Values( [106.780752584519, 83.6557999642181, 131.739275066723, 108.595538300447] )
),
New Column( "4hr Lactic",
Numeric,
"Nominal",
Format( "", 16 ),
Set Values( [117.501711811893, 110.280136421701, 99.5008817613032, 124.122069840277] )
),
New Column( "4hr Acetic",
Numeric,
"Nominal",
Format( "", 16 ),
Set Values( [65.8570956816124, 98.7590715244122, 116.085302666605, 77.465274192855] )
),
New Column( "60 hr Ethanol",
Numeric,
"Nominal",
Format( "", 16 ),
Set Values( [93.2946183359449, 102.663246654816, 88.3140432209597, 77.0616091856786] )
),
New Column( "60 hr Lactic",
Numeric,
"Nominal",
Format( "", 16 ),
Set Values( [115.208356681673, 94.3976953097385, 117.870933434213, 88.9448640120466] )
),
New Column( "60 hr Acetic",
Numeric,
"Nominal",
Format( "", 16 ),
Set Values( [101.707143312459, 115.87798730461, 111.256786967136, 114.046044409696] )
),
Set Row States( [1, 0, 0, 0] )
);
// Stack the columns
dtStack = dt << Stack(
columns(
:"0hr Ethanol"n, :"0 hr Lactic"n, :"0 hr Acetic"n, :"4hr Ethanol"n, :"4hr Lactic"n, :"4hr Acetic"n, :"60 hr Ethanol"n, :"60 hr Lactic"n,
:"60 hr Acetic"n
),
Source Label Column( "Label" ),
Stacked Data Column( "Data" )
);
// Create new time and Type of Gas
dtStack << New Column( "Time", Format( "h:m" ), set each value( Num( Word( 1, :label, "h" ) ) * 3600 ) );
For each row(:label = word(-1,:Label," "));
// Split out into separate columns
dtSplit dtStack << Split(
Split By( :Label ),
Split( :Data ),
Group( :Batch, :Time ),
Sort by Column Property
);
// Graph the data
Graph Builder(
Size( 528, 454 ),
Show Control Panel( 0 ),
Variables( X( :Time ), Y( :Ethanol ), Overlay( :Batch ) ),
Elements( Line( X, Y, Legend( 15 ) ), Points( X, Y, Legend( 16 ) ) ),
Local Data Filter(
Add Filter(
columns( :Batch ),
Where( :Batch == {1, 2} ),
Display( :Batch, N Items( 4 ) )
)
)
);
實際上,我曾經在這個行業工作過,並且對我們遇到的所有不同的數據格式有著美好的回憶…… 最常見的是您提供的水平數據格式。 Jim 是完全正確的,您需要對錶格進行堆疊和拆分。 我會對上面的腳本提出一個非常小的建議。 如果您在下面的行中使用格式“hr:m”,它將導致持續時間單位而不是一天中的時間。
玩得開心!
// Create new time and Type of Gas
dtStack << New Column( "Time", Format( "hr:m" ), set each value( Num( Word( 1, :label, "hr" ) ) * 3600 ) );