約 50 の異なる観測点で 1 時間ごとに測定されたデータを含む JMP テーブルがあります。各観測所では、データが ppm で報告される場合もあれば、ppb で報告される場合もあり、両方の単位で報告される場合もありますが、まったく測定がない場合もあります。これはかなり大規模なデータセットなので、各測点に関連する列を 1 つの単位系の 1 つの列に結合するのを自動化するにはどうすればよいか疑問に思っています。それとも、ステーションごとに新しい列を手動で作成し、変換を行うための式を入力する必要がありますか? Excel を使用せずに、このデータ準備ステップをスピードアップしようとしているだけです。
ありがとう。出来た!すべてが ppm 単位で表示されるようになったので、分析を続けることができます。
これは、あなたが示した構造を与えられたスクリプトで、すべてのデータをppmに変換し、ppb列を削除します。
これは単なる出発点であり、詳細により計算が変更される場合は、ロジックに含めることができます。
Names Default To Here( 1 );
dt = Current Data Table();
For( i = 1, i <= N Cols( dt ), i++,
If( Trim( Word( -1, Column( dt, i ) << get name, ":" ) ) == "ppm",
ppbCol = Trim( Substr( Column( dt, i ) << get name, 1, Contains( Column( dt, i ) << get name, "ppm" ) - 1 ) || "ppb" );
For( k = 1, k <= N Rows( dt ), k++,
Column( dt, i )[k] = Sum( Column( dt, i )[k], Column( dt, ppbCol )[k]/1000 )
);
)
);
// Get rid of ppb columns
For( i = N Cols( dt ), i >= 1, i--,
If( Trim( Word( -1, Column( dt, i ) << get name, ":" ) ) == "ppb",
dt << delete columns( i )
)
);
これを行うには多くの方法があることは間違いありませんが、例の列形式が一貫していると仮定して最初に思いついた方法は次のとおりです。 投稿の下部にあるスクリプトを実行して完全な例を確認するか、スクリプト内の緑色のコメントと以下のスクリーンショットに従うことができます。
Stack を使用して、すべてのステーション データを 1 つの列にまとめます。

Station の数式 (「きれいな」形式と、数式をダブルクリックしたときに表示されるコードの両方で表示されます:

単位の式も同様です。

各潜在的な単位のデータ アカウントの計算式は次のとおりです。

表の作成は、間隔とステーションの順序データ型または名義データ型に依存します。

次に、表作成メニューからデータ表に作成を使用します。
例を再作成するスクリプト:
//To see a full example you can copy this this into a new script window and press Run, or just following along
//with the green comments
Names default to here(1);
//Recreate part of your sample data table, you could skip this part and open your original data instead
//Note that the times are ordinal or nominal data types, this will be imporant in the tabulate platform later
dt = New Table( "Raw Data",
Add Rows( 2 ),
New Column( "IntervalStart", Numeric, "Ordinal", Format( "m/d/y h:m", 19 ), Input Format( "m/d/y" ),
Set Values( [3503606400, 3503610000] ),
),
New Column( "IntervalEnd", Numeric, "Ordinal", Format( "m/d/y h:m", 19 ), Input Format( "m/d/y h:m" ),
Set Values( [3503609940, 3503613540] )
),
New Column( "StationName: Anzac-Unit:ppb", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [1, 2] ) ),
New Column( "StationName: Anzac-Unit:ppm", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [., .] ) ),
New Column( "StationName: Ardrossan-Unit: ppb", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [., .] ) ),
New Column( "StationName: Ardrossan-Unit: ppm", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [11, 12] ) )
);
//Get a reference to your current data table
dt = Current data table();
//Stack all of the columns - use Tables > Stack and include all of the columns except the first two which are times
dtStacked = dt << Stack(
columns(
(dt << Get Column Names())[3::n col(dt)]
),
Source Label Column( "Label" ),
Stacked Data Column( "Data" )
);
//Now add three new columns to find the station and units, and calculate the concentration based on the units
//you should be able to copy and paste the part inside the 'Formula' function below into the formulas of your new columns
dtStacked << New Column("Station", Character, "Nominal", Formula(Words(:Label, "-")[1]));
dtStacked << New Column("Unit", Character, "Nominal", Formula(Words(:Label, "-")[2]), Set Display Width(65));
dtStacked << New Column("Data (ppm)", Numeric, "Continuous", Format("Best", 12), Formula(If(Contains(:Unit, "ppm"), :Data, Contains(:Unit, "ppb"), :Data / 1000)));
//Put back in standard format using the tabulate platform. Drag times and the station into
//columns on the left and add the mean and N as data fields. Note that in the resulting table anything
//with a N(Data) greater than 1 might have a problem!
(dtStacked << Tabulate(
Show Control Panel( 0 ),
Add Table(
Column Table( Analysis Columns( :Data ), Statistics( Mean, N ) ),
Row Table( Grouping Columns( :IntervalStart, :IntervalEnd, :Station ) )
)
)) << Make Into Data Table;
こんにちは、ジムさん
あなたの質問に答えて、データがどのように見えるかの写真を投稿しました。データを変更する手順を教えてください。
ありがとう。
こんにちは、
データはこんな感じです。列名には測点と測定単位が示されています。
よろしくお願いいたします。
データは数値として表示されますか (単位なし、または別のフィールドに単位が表示されます)、それとも単位が数字とともに表示される文字データとして表示されますか (例: 13ppm)?データがどのように表示されるかの例を示していただけるとわかりやすいでしょう。数式は希望の変換を行う必要がありますが、具体的にどのような数式がどのようなものであるかはデータの外観によって異なります。
非常に単純なスクリプトを使用して、入力された列の値を直接変更できます。または、再コード化ツールを使用して、対話形式で同じことを行うこともできます。測定単位はどのように決定しますか?それを示す別の列はありますか?