特定のカットオフ値を持つ列名を取得するこんにちは、
これらのデータ例から特定の列名を数えて取得しようとします(実際のデータには 180 列と 20000 行が含まれていました)
カットオフが1000を超える列を選択したい
| いいえ。 | A*1:01 | A*2:01 | B*9:02 | 10:01 ... | DR*56:01 | DP*07_G | 名前を取得 |
| 1 | 10.67 | 0 | 9520.23 | 15000.1 | 90.56 | 40.89 | B*9:02、C*10:01 |
| 2 | 0 | 0 | 0 | 0 | 0 | 9.56 | |
| 3 | 9040.3 | 345.3 | 345.9 | 999.9 | 345 | 10.5 | A*1:01 |
| 4 | 34.4 | 4566 | 45 | 7 | 0 | 0 | A*2:01 |
| 5 | 9190.2 | 13567 | 3456 | 6789 | 9088 | 0 | A*1:01、A*2:01、B*9:02、C*10:01、DR*56:01 |
| 6 | 0 | 0 | 0 | 0 | 0 | 0 | |
| ... | | | | | | | |
前回のスクリプトをこのように試します
Names Default To Here( 1 );
// Create a sample data table
dt = New Table( "Example",
Add Rows( 2 ),
New Column( "A*1:01", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 50000] ) ),
New Column( "A*2:01", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 50000] ) ),
New Column( "B*9:02", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 50000] ) ),
New Column( "C*10:01", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 50000] ) ),
New Column( "DR*56:01", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 50000] ) ),
//get wanted columns. Assumes that IMC columns start from column 1 and all IMC columns are one after another
colNames = dt << Get Column Names("String");
For(i = N Items(colNames), i > 3000 , i--,
);
//new column with IMC with value 1
dt << New Column( "Ag", Character,
<< Set Each Value(
rowValues = dt[Row(), 0][1::N Items(colNames)]; //get values of row as matrix
colIndex = Contains(rowValues, 1); //get index of
If(colIndex > 0, //handle
colNames[colIndex], //get column name with the index
""; //when no 1 found use ""
);
);
);私のスクリプトを修正していただけますか。ありがとうございます!
さらに、180 列の「新しい列」を生成する必要があるため、マトリックスを使用できますか。
最高、
データのブレンドとクリーンアップRe: 特定のカットオフ値を持つ列名を取得する私はこう対処します

names default to here(1);
dt = New Table( "Example",
Add Rows( 6 ),
New Column( "A*1:01",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values(
[10.67, 0, 9040.2999999999993, 34.399999999999999, 9190.2000000000007, 0
]
)
),
New Column( "A*2:01",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [0, 0, 345.30000000000001, 4566, 13567, 0] )
),
New Column( "B*9:02",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [9520.2299999999996, 0, 345.89999999999998, 45, 3456, 0] )
),
New Column( "C*10:01",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [15000.1, 0, 999.89999999999998, 7, 6789, 0] )
),
New Column( "DR*56:01",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [90.560000000000002, 0, 345, 0, 9088, 0] )
),
New Column( "DP*07_G",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [40.890000000000001, 9.5600000000000005, 10.5, 0, 0, 0] )
)
);
dt << New Column( "Get Name",character);
colNames = dt << get column names( continuous,string );
For Each Row(
theList = {};
For Each( {col, i}, colNames,
If( As Column( col ) > 3000,
Insert Into( theList, col )
)
);
:Get Name = Concat Items( theList, "," );
);
Re: 特定のカットオフ値を持つ列名を取得するこんにちは、ジムさん
ご協力ありがとうございます。ただし、異なる単語に 180 列と 20000 行があり、すべてを次のスクリプトのように配置することはできません。さらに提案をいただけませんか?
ありがとう
Re: 特定のカットオフ値を持つ列名を取得するこれは十分速いかもしれない
Names Default To Here(1);
// Create a sample data table
dt = New Table("Example",
Add Rows(20000),
invisible
);
colcount = 200;
For(i = 1, i <= colcount, i++,
newcol = dt << New Column(Char(i), Numeric, Continuous, Formula(
Random Normal() * 1000
));
dt << run formulas;
newcol << delete formula;
);
start = Tick Seconds();
colnames = dt << Get Column Names("String");
newcol = dt << New Column("getname", Character, Nominal, Formula(
valid_idx = Loc(dt[Row(), colnames] > 1000);
If(N Items(valid_idx) > 0,
Concat Items(colnames[valid_idx], ", ")
,
""
);
));
dt << run formulas;
newcol << delete formula;
wait(0);
end = Tick Seconds();
show(end - start);Re: 特定のカットオフ値を持つ列名を取得するこんにちは、ジャーモさん
ありがとうございます。しかし、結果は「end - start = 0.0333333333255723;」です。これは新しいテーブルではありません。もっと解決策を提供していただけますか? JMP の次のデータ テーブルを表示してください。
ありがとう
Re: 特定のカットオフ値を持つ列名を取得する私のスクリプトは値を持つ新しい列「getname」を作成します

データで、列を数値に固定した後(列なしを削除した後)

Re: 特定のカットオフ値を持つ列名を取得するこんにちは、ジャーモさん
ご協力ありがとうございます。しかし、正直に言うと、以下の添付ファイルのようにスクリプトを実行することができません。以下に示すスクリプト (コマンド + 1) を確認したところ、実行できませんでした。ご協力ありがとうございます。
dt = New Table("Example",
Add Rows(20000),
invisible
);
colcount = 200;
For(i = 1, i <= colcount, i++,
newcol = dt << New Column(Char(i), Numeric, Continuous, Formula(
Random Normal() * 1000
));
dt << run formulas;
newcol << delete formula;
);
start = Tick Seconds();
colnames = dt << Get Column Names("String");
newcol = dt << New Column("getname", Character, Nominal, Formula(
valid_idx = Loc(dt[Row(), colnames] > 1000);
If(N Items(valid_idx) > 0,
Concat Items(colnames[valid_idx], ", ")
,
""
);
));
dt << run formulas;
newcol << delete formula;
wait(0);
end = Tick Seconds();
show(end - start);
/*:
end - start = 0.683333333348855;
Re: 特定のカットオフ値を持つ列名を取得するテーブルを開いて列を修正し、新しい列が作成される部分を実行する必要があります。
Names Default To Here(1);
dt = Open("$DOWNLOADS/Examples_get column name_by cutoff.jmp", invisible);
colnames = Remove(dt << Get Column Names("String"), 1); // drop No column
// Fix data and modeling types
For Each({colname}, colnames,
Column(dt, colname) << Data Type("Numeric") << Modeling Type("Continuous");
);
newcol = dt << New Column("getname", Character, Nominal, Formula(
valid_idx = Loc(dt[Row(), colnames] > 1000);
If(N Items(valid_idx) > 0,
Concat Items(colnames[valid_idx], ", ")
,
""
);
));
dt << run formulas;
newcol << delete formula;
JMPヘルプのスクリプトガイドを確認することを強くお勧めします。
Re: 特定のカットオフ値を持つ列名を取得するこんにちは、Jarmoさん。カットオフを超える値(列が50列ある場合)を各列名(例のgetname列)で抽出する方法はありますか?
Re: 特定のカットオフ値を持つ列名を取得するどのように抽出しますか? 私のソリューションでは、列名が , とスペースで区切られた文字列として含まれる新しい列が作成されませんか?

行ではなく列ごとに値をチェックしますか? それとも他の方法ですか?
編集:
異なる列リストだけが必要な場合は、フィルタリング方法を知る必要があります。すべての列だけが必要な場合は、Remove()関数を削除します。
Names Default To Here(1);
dt = Open("$DOWNLOADS/Examples_get column name_by cutoff.jmp", invisible);
colnames = dt << Get Column Names("String");
For Each({colname}, colnames,
Column(dt, colname) << Data Type("Numeric") << Modeling Type("Continuous");
);
For(i = 1, i < 100, i++,
newcol = dt << New Column(Hex(i), Numeric, Nominal, Values(J(1, N Rows(dt), Random Normal()*1000)));
);
colnames = dt << Get Column Names("String");
newcol = dt << New Column("getname", Character, Nominal, Formula(
valid_idx = Loc(dt[Row(), colnames] > 1000);
If(N Items(valid_idx) > 0,
Concat Items(colnames[valid_idx], ", ")
,
""
);
));
dt << run formulas;
newcol << delete formula;Re: 特定のカットオフ値を持つ列名を取得する多数の列がある場合に役立つ代替方法があります
Names Default To Here( 1 );
dt = Open("$DOWNLOADS/Examples_get column name_by cutoff.jmp");
colnames = Remove( dt << Get Column Names( "String" ), 1 ); // drop No column
// Fix data and modeling types
For Each({colname}, colnames,
Column(dt, colname) << Data Type("Numeric") << Modeling Type("Continuous");
);
dtStack = dt << Stack(
columns( colnames ),
Source Label Column( "ColName" ),
Stacked Data Column( "Value" ),
Output Table( "The Stack" )
);
dtStack << select where( :value <= 1000 );
dtStack << delete rows;
dtStack << delete columns( Value );
dtSplit = dtStack << Split(
Split By( :ColName ),
Split( :ColName ),
Group( :No ),
Output Table( "Split of The Stack by ColName" ),
Sort by Column Property
);
close( dtStack, nosave );
colnames = Remove( dtSplit << Get Column Names( "String" ), 1 );
dtSplit << Combine Columns(
delimiter( "," ),
columns( colnames ),
Column Name( "Get Name" )
);
dtSplit << delete columns( colnames );
dt << Update( With( dtSplit ), Match Columns( :No = :No ) );
Close( dtSplit, nosave );Re: 特定のカットオフ値を持つ列名を取得する
ありがとうございます。この点について明確にしたいと思います。「関心のあるアルファベット」として関心のある別の列があり、値が 1,000 を超えるすべての列の名前と値を取得し、すべての列が関心のある列のアルファベットと一致するようにしたいと考えています。
ありがとう!
Re: 特定のカットオフ値を持つ列名を取得するありがとう、ジム。しかし、うまくいきません。添付ファイルを参照してください。
Re: 特定のカットオフ値を持つ列名を取得するジムが提案したようなことをする方がおそらく速くて簡単ですが、私が実演した方法でもこのようなことができます
Names Default To Here(1);
dt = Open("$DOWNLOADS/Examples_get column name_by cutoff.jmp", invisible);
Summarize(dt, alphs = By(:"Alphabet of interest"n));
aa = Associative Array(alphs, Repeat({{}}, N Items(alphs)));
collist = dt << Get Column Names("String");
For Each({colname}, collist,
alph = Word(1, colname, "*");
If(Contains(aa, alph),
Insert Into(aa[alph], colname);
Column(dt, colname) << Set Data Type("Numeric") << Modeling Type("Continuous");
);
);
str_template = "^col^ (^val^)";
newcol = dt << New Column("getname", Character, Nominal, Formula(
cols = aa[:"Alphabet of interest"n];
vals = dt[Row(), aa[:"Alphabet of interest"n]];
valid_idx = Loc(vals > 1000);
If(N Items(valid_idx) > 0,
res = {};
For Each({{col, val}}, Across(cols[valid_idx], vals[valid_idx]),
Insert Into(res, Eval Insert(str_template));
);
Concat Items(res, ", ");
,
""
);
));
dt << run formulas;
newcol << delete formula;
dt << show window(1);

Re: 特定のカットオフ値を持つ列名を取得するスクリプトが「No」という列の後に数値列が続くように記述されている場合、提供されたデータ テーブルには数値列に加えて 2 つの文字列列があります。「対象のアルファベット」列と「名前と値を取得」列を削除してからスクリプトを実行すると、正常に動作します。
追加の列を補うためにスクリプトを簡単に変更できるはずです。列名の取得を開始する前にスクリプト内で列名を削除するか、For Each を処理する前に列名リストから列名を削除すると、機能するはずです。
Re: 特定のカットオフ値を持つ列名を取得するありがとうございます。このスクリプトは動作します。ただし、元のデータがこれよりも複雑だったことをお詫びします。対象のアルファベットには、添付ファイルとして「、」で区切られた複数の「アルファベット」と「数字」(A1、B9)があります。対象のアルファベット列と列名を関連付けた名前と値の列を取得するにはどうすればよいでしょうか。

助けてくれてありがとう。
Re: 特定のカットオフ値を持つ列名を取得するこれらの「アルファベット」はどのように決定されるのでしょうか? 最後の「_」の後のすべてですか? その場合は、スクリプトにわずかな変更を加えて、最初の単語の代わりに最後の単語を取り、別の区切り文字を使用すればよいので、この部分にはわずかな変更が必要です。
alph = Word(1, colname, "*");
Re: 特定のカットオフ値を持つ列名を取得するご提案ありがとうございます。「:」の前の最初の単語を一致させたい場合、次のようにします。
alph = Word(1, colname, ":");
そして「_」の後の最後の単語を一致させたい場合、次のようにします
alph = Word(-1, colname, "_");
「:」の前と「_」の後に同時に一致させる必要がある場合はどうすればよいでしょうか? 上記のそれぞれに対して実行したスクリプトを結合した後、重複 (まったく同じもの) を処理することができませんでした。
ありがとう
Re: 特定のカットオフ値を持つ列名を取得するテーブルの開始と終了を見ると異なります (開始 A*1 と終了 A1)。そのため、比較を実行し、後で重複を処理するには、これらの「追加」キーを連想配列に追加する必要があります。
Re: 特定のカットオフ値を持つ列名を取得するさらに、対象のアルファベットの列に 1 を超える数値があった場合、スクリプトは実行されませんでした。これについて何か提案はありますか?
ありがとう!
Re: 特定のカットオフ値を持つ列名を取得する私のスクリプトは、あなたが提供した状況に対応しました。実際の質問によっては、スクリプトを完全に書き直す必要がある場合もあれば、少し修正するだけで済む場合もあります。
Re: 特定のカットオフ値を持つ列名を取得するJarmo さん、ありがとうございます。ここでやりたいことと互換性のあるファイルを添付したいと思います。DOA と DO で構成されるアルファベット列を、DOA1*0x:0x、DOB1*0x:0x_DOx の各列と一致させたいと思います。DOA0x は DOA1*0x (「:」の後は含みません) と一致し、DOx または DOB1*Ox は DOx と一致します。結果列に表示されるには、これらすべての値が 1000 を超える必要があります。おっしゃるとおり、既存の数式を修正することはできません。よろしくお願いします。
Re: 特定のカットオフ値を持つ列名を取得するDOA1*0x が DOx と一致しないのはなぜですか?
Re: 特定のカットオフ値を持つ列名を取得するここに何らかのスクリプトがあります。正しいルールについてはまだ推測するしかないので、期待通りに動作するかどうかはわかりません。
Names Default To Here(1);
dt = Open("$DOWNLOADS/Examples_get column name_edit.jmp");
// fix data
For Each({colname}, dt << Get Column Names("Character", "String"),
If(colname == "Alphabet",
break();
);
Column(dt, colname) << Set Data Type("Numeric") << Set Modeling Type("Continuous");
);
dt << Delete Columns("get name and value");
dt << New Column("R", Numeric, Ordinal, Formula(Row()));
dt_stacked = dt << Stack(
columns(
:"DOA1*01:01,DOB1*01:01_DO1"n, :"DOA1*02:01,DOB1*01:01_DO1"n,
:"DOA1*03:01,DOB1*01:01_DO1"n, :"DOA1*02:01,DOB1*02:01_DO2"n,
:"DOA1*01:05,DOB1*02:01_DO2"n, :"DOA1*04:03,DOB1*03:01_DO3"n,
:"DOA1*06:01,DOB1*04:01_DO4"n, :"DOA1*05:01,DOB1*03:01_DO7"n
),
Source Label Column("Label"),
Stacked Data Column("Data"),
Output Table("stacked")
);
rows_to_delete = dt_stacked << Get Rows Where(:Data <= 1000);
dt_stacked << Delete Rows(rows_to_delete);
dt_stacked << New Column("Match", Numeric, Nominal);
For Each Row(dt_stacked,
alphs = Words(:Alphabet, ",");
temp_label = Regex(:Label, "(\d\*)", "", GLOBALREPLACE);
retval = 0;
For Each({alph}, alphs,
If(Contains(temp_label, alph),
retval = 1;
break();
);
);
:Match = retval;
);
rows_to_delete = dt_stacked << Get Rows Where(:Match == 0);
dt_stacked << Delete Rows(rows_to_delete);
dt_stacked << New Column("NewStr", Character, Nominal, Formula(
:Label || " (" || Char(:Data) || ")"
));
Summarize(dt_stacked, rs = By(:R));
fixed_rs = Transform Each({r}, rs, Num(r));
vals = Associative Array();
For Each({r}, fixed_rs,
t = dt_stacked << Get Rows Where(:R == r);
vals[r] = Concat Items(dt_stacked[t, "NewStr"], ",");
);
Close(dt_ stacked);
new_col = dt << New Column("Res", Character, Nominal, Formula(
If(Contains(vals, :R),
vals[:R]
,
""
);
));
dt << run formulas;
new_col << Delete Formula;
Re: 特定のカットオフ値を持つ列名を取得するそれは生物学と一致しません。
Re: 特定のカットオフ値を持つ列名を取得するありがとう、Jarmo。仕事だよ!