大家好,
我正在尝试集成 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 ) );