특정 컷오프 값이 있는 열 이름 가져오기안녕,
이 데이터 예제에서 특정 열 이름을 계산하고 얻으려고 합니다(실제 데이터에는 180개의 열과 20000개의 행이 포함되어 있습니다).
컷오프 > 1000인 열을 선택하고 싶습니다.
| 아니요. | A*1:01 | A*2:01 | B*9:02 | C*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: 특정 구분값이 있는 열 이름을 가져오는 중입니다.안녕하세요 Jarmo님,
매우 감사합니다. 그러나 결과는 "end - start = 0.0333333333255723;"입니다. 그 테이블은 새 테이블이 아닙니다. 더 많은 솔루션을 제공해 주실 수 있나요? JMP에서 다음 데이터 테이블을 보여주세요.
감사합니다
Re: 특정 구분값이 있는 열 이름을 가져오는 중입니다.내 스크립트는 값을 사용하여 새 열 "getname"을 생성합니다.

데이터를 사용하여 열을 숫자로 수정하고 열 없음을 삭제한 후

Re: 특정 구분값이 있는 열 이름을 가져오는 중입니다.안녕하세요 Jarmo님,
도움을 주셔서 감사합니다. 하지만 솔직히 말해서 다음 첨부 파일처럼 스크립트를 실행할 수 없습니다. 아래의 스크립트(command+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, 각 열 이름(예제에서 getname 열)을 사용하여 50개의 열이 있는 경우 이 값 중 컷오프보다 큰 값을 추출하는 방법에 대한 아이디어가 있습니까?
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: 특정 차단 값이 있는 열 이름 가져오기Jim이 제안한 것과 같은 작업을 하는 것이 더 빠르고 쉽겠지만 내가 보여준 방법으로 이와 비슷한 작업을 할 수 있습니다.
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: 특정 차단 값이 있는 열 이름 가져오기스크립트가 "아니요"라는 열과 숫자 열로 실행되도록 작성되었다면, 제공된 데이터 테이블에는 숫자 외에도 문자 열이 2개 있습니다. "관심 있는 알파벳"과 "이름과 값 가져오기" 열을 제거한 다음 스크립트를 실행하면 잘 작동합니다.
추가 열을 보상하기 위해 스크립트를 쉽게 변경할 수 있어야 합니다. 열 이름을 검색하기 시작하기 전에 스크립트에서 삭제하거나, For Each를 처리하기 전에 열 이름 목록에서 삭제하면 됩니다.
Re: 특정 차단 값이 있는 열 이름 가져오기정말 감사합니다. 이 스크립트는 작동합니다. 하지만 제 원래 데이터가 이보다 더 복잡해서 죄송합니다. 관심 있는 알파벳에는 첨부 파일로 ","로 구분된 여러 개의 "알파벳"과 "숫자"가 있습니다(A1, B9). 관심 있는 알파벳 열과 열 이름을 연관시키는 이름과 값 열을 어떻게 얻을 수 있습니까?

귀하의 도움에 감사드립니다.
Re: 특정 차단 값이 있는 열 이름 가져오기그 "알파벳"은 어떻게 결정되나요? 마지막 "_" 뒤에 있는 모든 것인가요? 그렇다면 제 스크립트를 아주 약간 수정해서 첫 번째 단어 대신 마지막 단어를 사용하고 다른 구분 기호를 사용할 수 있을 텐데, 그래서 이 부분은 약간 수정해야 합니다.
alph = Word(1, colname, "*");
Re: 특정 차단 값이 있는 열 이름 가져오기제안해 주셔서 감사합니다. ":" 앞의 첫 번째 단어를 일치시키고 싶다면 다음과 같아야 합니다.
alph = Word(1, colname, ":");
그리고 "_" 뒤에 있는 마지막 단어와 일치하려면 다음과 같아야 합니다.
alph = Word(-1, colname, "_");
":" 앞과 "_" 뒤에 동시에 매치해야 하는 경우는 어떻게 하나요? 위의 각 항목에 대해 실행한 스크립트를 합친 후, duplicate(똑같은 것)로 관리할 수 없었습니다.
감사합니다
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. 일이잖아요!