列を行に変換する
データと望ましい結果
ご協力をよろしくお願いします
品質およびプロセスエンジニアリング結果の共有と伝達Re: 列を行に転置する JSL スクリプトありがとう、ジム
Re: 列を行に転置する JSL スクリプト私の間違いです...間違って、私があなたに送った最後のエントリには私の修正が含まれていませんでした。 前回の回答を編集し、JSL を更新しました。 戻って JSL をプルして実行してください。 修正されたコードが含まれています。Re: 列を行に転置する JSL スクリプトジムに感謝しますが、何らかの理由で更新されたスクリプトでも同じエラーが発生します

Re: 列を行に転置する JSL スクリプト問題は、1 つ以上のパラメータが文字データとして入力されていることです。Transpose は混合データを処理できません。そこで、検出されたすべてのパラメータが数値であることを確認するチェックを追加しました。
Names Default To Here( 1 );
dt = Current Data Table();
// Transpose the Demographics
dtTrans1 = dt << Transpose(
columns( :SBIN, :HBIN, :Alarms, :Device, :Site ),
Transpose selected rows only( 1 ),
Output Table( "Transpose 1" )
);
// Change the name of the first column
dtTrans1:Label << set name( "Column 1" ) << Set Display Width( 150 );
// Change the new column names
For( i = 2, i <= N Cols( dtTrans1 ), i++,
Column( dtTrans1, i ) << set name( "Column " || Char( i + 4 ) ) << Set Display Width( 100 )
);
// Change the detail name of the Alarms
dtTrans1:Column 1[(dtTrans1 << get rows where( dtTrans1:Column 1 == "Alarms" ))[1]] = "Pass/Fail/Alarm";
// Create the Devce values
deviceRow = (dtTrans1 << get rows where( dtTrans1:Column 1 == "Device" ))[1];
For( i = 2, i <= N Cols( dtTrans1 ), i++,
Column( dtTrans1, i )[deviceRow] = i - 1
);
// Now Find all of the columns that are parameters
parameterColNamesList = {};
For( i = 1, i <= N Cols( dt ), i++,
If( Is Missing( Num( Word( 1, Column( dt, i ) << get name, ":" ) ) ) == 0 &
Column( dt, i ) << get modeling type == "Continuous",
Insert Into( parameterColNamesList, Column( dt, i ) << get name )
)
);
// Transpose the parameter columns
dtTrans2 = dt << Transpose(
columns( Eval( parameterColNamesList ) ),
Transpose selected rows only( 0 ),
Output Table( "Transpose 2" )
);
// Add in the new columns to be created
dtTrans2 << Add Multiple Columns( "Column", 5, before first, Character );
// Add the columns 2-5 in the trans data table
dtTrans1 << Add Multiple Columns( "xColumn", 4,after(:Column 1), Character );
for(i=2,i<=5,i++,
column(dtTrans1,i)<<SET name=""></SET>Re: 列を行に転置する JSL スクリプトここに一つあります
Re: 列を行に転置する JSL スクリプト表示されるエラー メッセージは、「dtTrans2」が指すデータ テーブルが作成されていないことを示します。「dtTrans2」は Transpose() から作成されます。これには、元のデータ テーブルからのパラメーターのリストが必要です。「parameterColNamesList」は、元のデータ テーブル内で数字で始まり、その後に「:」が続くすべての列を検索することによって作成されます。パラメータは元のデータテーブルのような名前ではないのではないかと思います。ただし、データテーブルを見ないので、推測するだけです。私の推測が正しい場合は、パラメーター列を識別する何かを見つける必要があります。
Re: 列を行に転置する JSL スクリプトこんにちは、ジム
何らかの理由で他のデータテーブルに問題がまだ見つかりました。データタイプをチェックして、それらがすべて同じであることを確認しました。しかしそれは機能しません

Re: 列を行に転置する JSL スクリプトありがとう、ジム
Re: 列を行に転置する JSL スクリプトこのサンプル データ テーブルには、Device 列に問題があります。文字データ型として設定されます。これを数値に変更すると、スクリプトは正常に動作します。
Re: 列を行に転置する JSL スクリプト提供されたサブセット サンプル データに対してスクリプトを実行したところ、エラーなしで実行され、転置されたデータ テーブルが生成されました。小さな問題が 1 つ見つかりました。それは、テスト名に入力データ テーブルの完全な名前が含まれていないということでした。しかし、それ以外は正常に動作しているようです。

修正されたJSLは次のとおりです
Names Default To Here( 1 );
dt = Current Data Table();
// Transpose the Demographics
dtTrans1 = dt << Transpose(
columns( :SBIN, :HBIN, :Alarms, :Device, :Site ),
Transpose selected rows only( 1 ),
Output Table( "Transpose 1" )
);
// Change the name of the first column
dtTrans1:Label << set name( "Column 1" ) << Set Display Width( 150 );
// Change the new column names
For( i = 2, i <= N Cols( dtTrans1 ), i++,
Column( dtTrans1, i ) << set name( "Column " || Char( i + 4 ) ) << Set Display Width( 100 )
);
// Change the detail name of the Alarms
dtTrans1:Column 1[(dtTrans1 << get rows where( dtTrans1:Column 1 == "Alarms" ))[1]] = "Pass/Fail/Alarm";
// Create the Devce values
deviceRow = (dtTrans1 << get rows where( dtTrans1:Column 1 == "Device" ))[1];
For( i = 2, i <= N Cols( dtTrans1 ), i++,
Column( dtTrans1, i )[deviceRow] = i - 1
);
// Now Find all of the columns that are parameters
parameterColNamesList = {};
For( i = 1, i <= N Cols( dt ), i++,
If( Is Missing( Num( Word( 1, Column( dt, i ) << get name, ":" ) ) ) == 0,
Insert Into( parameterColNamesList, Column( dt, i ) << get name )
)
);
// Transpose the parameter columns
dtTrans2 = dt << Transpose(
columns( Eval( parameterColNamesList ) ),
Transpose selected rows only( 0 ),
Output Table( "Transpose 2" )
);
// Add in the new columns to be created
dtTrans2 << Add Multiple Columns( "Column", 5, before first, Character );
// Add the columns 2-5 in the trans data table
dtTrans1 << Add Multiple Columns( "xColumn", 4,after(:Column 1), Character );
for(i=2,i<=5,i++,
column(dtTrans1,i)<<SET name=""></SET>Re: 列を行に転置する JSL スクリプト前のサンプルは無視して、このサンプルを使用してください
Re: 列を行に転置する JSL スクリプトこれはランダムなサンプルデータです
Re: 列を行に転置する JSL スクリプトはい、確かにここです
Re: 列を行に転置する JSL スクリプト1 行目から 26 行目までのコードを実行してみてください。必要なのは、スクリプト内のこれらの行を選択 (ハイライト表示) し、[実行] アイコンをクリックすることだけです。
Names Default To Here( 1 );
dt = Current Data Table();
// Transpose the Demographics
dtTrans1 = dt << Transpose(
columns( :SBIN, :HBIN, :Alarms, :Device, :Site ),
Transpose selected rows only( 1 ),
Output Table( "Transpose 1" )
);
// Change the name of the first column
dtTrans1:Label << set name( "Column 1" ) << Set Display Width( 150 );
// Change the new column names
For( i = 2, i <= N Cols( dtTrans1 ), i++,
Column( dtTrans1, i ) << set name( "Column " || Char( i + 4 ) ) << Set Display Width( 100 )
);
// Change the detail name of the Alarms
dtTrans1:Column 1[(dtTrans1 << get rows where( dtTrans1:Column 1 == "Alarms" ))[1]] = "Pass/Fail/Alarm";
// Create the Devce values
deviceRow = (dtTrans1 << get rows where( dtTrans1:Column 1 == "Device" ))[1];
For( i = 2, i <= N Cols( dtTrans1 ), i++,
Column( dtTrans1, i )[deviceRow] = i - 1
);
Transpose 1 データ テーブルが次のようになっているかどうかを確認します。

30行目から35行目を実行します
parameterColNamesList = {};
For( i = 1, i <= N Cols( dt ), i++,
If( Is Missing( Num( Word( 1, Column( dt, i ) << get name, ":" ) ) ) == 0,
Insert Into( parameterColNamesList, Column( dt, i ) << get name )
)
);
そして、parameterColNamesList にデータ テーブル内のすべてのテストの名前が含まれているかどうかを確認します。
次に、正しく実行されていない部分が見つかるまで、コードのさまざまなセクションをチェックし続けます。
読み込もうとしているデータテーブルのコピーを提供していただければ、私自身で確認させていただきます。
Re: 列を行に転置する JSL スクリプトログエラーはありません。スクリプトを実行しても何も起こりません。唯一の違いはテスト名です...それらは異なります。ただし、他のヘッダーはすべて同じですRe: 列を行に転置する JSL スクリプトログにエラー メッセージはありますか?
2 つのデータ テーブルの違いは何ですか?
スクリプトが完了する前に停止していませんか?
Re: 列を行に転置する JSL スクリプトありがとうジム!フォーマットは完璧です。ただし、何らかの理由で他の同様のデータセットでは機能しません。何か理由はありますか?
Re: 列を行に転置する JSL スクリプトこれは、仕様列などを正しい位置に配置し、列ラベルも追加するスクリプトの修正バージョンです。
Names Default To Here( 1 );
dt = Current Data Table();
// Transpose the Demographics
dtTrans1 = dt << Transpose(
columns( :SBIN, :HBIN, :Alarms, :Device, :Site ),
Transpose selected rows only( 1 ),
Output Table( "Transpose 1" )
);
// Change the name of the first column
dtTrans1:Label << set name( "Column 1" ) << Set Display Width( 150 );
// Change the new column names
For( i = 2, i <= N Cols( dtTrans1 ), i++,
Column( dtTrans1, i ) << set name( "Column " || Char( i + 4 ) ) << Set Display Width( 100 )
);
// Change the detail name of the Alarms
dtTrans1:Column 1[(dtTrans1 << get rows where( dtTrans1:Column 1 == "Alarms" ))[1]] = "Pass/Fail/Alarm";
// Create the Devce values
deviceRow = (dtTrans1 << get rows where( dtTrans1:Column 1 == "Device" ))[1];
For( i = 2, i <= N Cols( dtTrans1 ), i++,
Column( dtTrans1, i )[deviceRow] = i - 1
);
// Now Find all of the columns that are parameters
parameterColNamesList = {};
For( i = 1, i <= N Cols( dt ), i++,
If( Is Missing( Num( Word( 1, Column( dt, i ) << get name, ":" ) ) ) == 0,
Insert Into( parameterColNamesList, Column( dt, i ) << get name )
)
);
// Transpose the parameter columns
dtTrans2 = dt << Transpose(
columns( Eval( parameterColNamesList ) ),
Transpose selected rows only( 0 ),
Output Table( "Transpose 2" )
);
// Add in the new columns to be created
dtTrans2 << Add Multiple Columns( "Column", 5, before first, Character );
// Add the columns 2-5 in the trans data table
dtTrans1 << Add Multiple Columns( "xColumn", 4,after(:Column 1), Character );
for(i=2,i<=5,i++,
column(dtTrans1,i)<<SET name=""></SET>Re: 列を行に転置する JSL スクリプトjmp14を使用しています
Re: 列を行に転置する JSL スクリプトJMP のどのバージョンを使用していますか?Re: 列を行に転置する JSL スクリプトありがとう!これはうまくいくようです。 しかし、何らかの理由で、テスト名の下限値と上限値の列が最後に配置されます。それらを再配置してスクリプト内でラベルを付ける方法はありますか?
Re: 列を行に転置する JSL スクリプト以下のスクリプトは、要求した出力テーブルの作成を開始するのに適しています。
Names Default To Here( 1 );
dt = Current Data Table();
// Transpose the Demographics
dtTrans1 = dt << Transpose(
columns( :SBIN, :HBIN, :Alarms, :Device, :Site ),
Transpose selected rows only( 1 ),
Output Table( "Transpose 1" )
);
// Change the name of the first column
dtTrans1:Label << set name( "Column 1" ) << Set Display Width( 150 );
// Change the new column names
For( i = 2, i <= N Cols( dtTrans1 ), i++,
Column( dtTrans1, i ) << set name( "Column " || Char( i + 4 ) ) << Set Display Width( 100 )
);
// Change the detail name of the Alarms
dtTrans1:Column 1[(dtTrans1 << get rows where( dtTrans1:Column 1 == "Alarms" ))[1]] = "Pass/Fail/Alarm";
// Create the Devce values
deviceRow = (dtTrans1 << get rows where( dtTrans1:Column 1 == "Device" ))[1];
For( i = 2, i <= N Cols( dtTrans1 ), i++,
Column( dtTrans1, i )[deviceRow] = i - 1
);
// Now Find all of the columns that are parameters
parameterColNamesList = {};
For( i = 1, i <= N Cols( dt ), i++,
If( Is Missing( Num( Word( 1, Column( dt, i ) << get name, ":" ) ) ) == 0,
Insert Into( parameterColNamesList, Column( dt, i ) << get name )
)
);
// Transpose the parameter columns
dtTrans2 = dt << Transpose(
columns( Eval( parameterColNamesList ) ),
Transpose selected rows only( 0 ),
Output Table( "Transpose 2" )
);
// Add in the new columns to be created
dtTrans2 << Add Multiple Columns( "Column", 5, before first, Character );
// Add the values to the new columns
For( i = 1, i <= N Rows( dtTrans2 ), i++,
dtTrans2:Column 1[i] = Word( 1, dtTrans2:Label[i], ":" );
dtTrans2:Column 2[i] = Word( 2, dtTrans2:Label[i], ":" );
specs = Column( dt, dtTrans2:Label[i] ) << get property( "spec limits" );
If( Is Missing( specs["LSL"] ) == 0,
dtTrans2:Column 3[i] = specs["LSL"]
);
If( Is Missing( specs["USL"] ) == 0,
dtTrans2:Column 4[i] = specs["USL"]
);
If( Column( dt, dtTrans2:Label[i] ) << get property( "Units" ) != "",
dtTrans2:Column 5[i] = Column( dt, dtTrans2:Label[i] ) << get property( "Units" )
);
);
// Get rid of the label column which is no longer needed
dtTrans2 << delete columns( :Label );
// Change the names of the Trans2 table to match the names in the Trans1 table
For( i = 6, i <= N Cols( dtTrans2 ), i++,
Column( dtTrans2, i ) << set name( "Column " || Char( i ) )
);
// Combine the 2 Transformed data tables
dtFinal = dtTrans1 << concatenate( dtTrans2 );
// Cleanup the no longer needed data tables
close( dtTrans1, nosave );
close( dtTrans2, nosave );