예, 다양한 야채 수로 인해 더 복잡해집니다. 수식보다는 스크립트에서 연결 값을 작성하는 것이 더 쉬울 것입니다.
이 버전의 스크립트를 보고 내가 어떻게 하는지 확인하십시오.
orig = New Table( "Fruit vs Veggies",
Add Rows( 48 ),
New Column( "Fruit",
Character,
"Nominal",
Set Values(
{"Polb", "Polb", "Polb", "Polb", "Polb", "Polb", "Polb", "Polb", "Polb", "Polb",
"Polb", "Polb", "Polb", "Polb", "Polb", "Polb", "Polb", "Polb", "Polb", "Polb",
"Polb", "Polb", "Polb", "Polb", "Polb", "Polb", "Polb", "Chrnb2", "Chrnb2", "Chrnb2",
"Chrnb2", "Chrnb2", "Chrnb2", "Chrnb2", "Chrnb2", "Chrnb2", "Chrnb2", "Chrnb2",
"Chrnb2", "Chrnb2", "Chrnb2", "Chrnb2", "Chrnb2", "Chrnb2", "Chrnb2", "Chrnb2",
"Chrnb2", "Chrnb2"}
)
),
New Column( "Vegetable",
Character,
"Nominal",
Set Values(
{"nuclear chromosome", "cellular_component", "intracellular", "cell", "nucleus",
"chromosome", "organelle", "immune system process", "biological_process",
"anatomical structure development", "DNA metabolic process",
"cellular nitrogen compound metabolic process", "molecular_function", "cytoplasm",
"cytoskeleton", "DNA binding", "nucleotidyltransferase activity",
"biosynthetic process", "response to stress", "cell death", "signal transduction",
"cytoskeletal protein binding", "lyase activity", "enzyme binding",
"homeostatic process", "ion binding", "protein complex",
"cellular component assembly", "cellular nitrogen compound metabolic process",
"transmembrane transport", "ion binding", "cell proliferation",
"immune system process", "nervous system process", "response to stress",
"cell-cell signaling", "molecular_function", "cell", "cell morphogenesis",
"biological_process", "anatomical structure development", "cell differentiation",
"transport", "signal transduction", "plasma membrane", "cellular_component",
"signal transducer activity", "transmembrane transporter activity"}
)
),
New Column( "Vegetable number",
Numeric,
"Nominal",
Format( "Best", 9 ),
Formula( Col Rank( :Vegetable, :Fruit ) )
)
);
split = orig << Split(
Split By( :Vegetable number ),
Split( :Vegetable ),
Group( :Fruit ),
Sort by Column Property
);
vc = {};
For( i = 1, i <= N Row( split ), i++,
vc[i] = Column( 2 )[i];
For( j = 3, j <= N Col( split ), j++,
If( Column( j )[i] != "",
vc[i] = vc[i] || ", " || Column( j )[i]
)
);
);
split << New Column( "Veggies_concat", character, set values( vc ) );안녕 제프,
빠른 답장을 보내 주셔서 감사합니다.문제에 대한 귀하의 설명은 중지입니다.
그러나 야채 종류의 수는 각 과일에 따라 다를 수 있으므로 채워지는 열의 수가 달라집니다. 이로 인해 끝에 추가 쉼표/구분 기호(정리 가능)가 생깁니다. 또한 일단 스크립트를 작성하면 스크립트가 실행될 때마다 다양한 항목(예: 야채)의 수를 자동으로 조정할 수 없습니다.
분할 단계 후 열 수를 자동으로 조정할 수 있다는 제안이 있으면 감사하겠습니다.
정말 감사합니다
세바스티앙
New Table( "Fruit vs Veggies",
Add Rows( 48 ),
New Script(
"Source",
Data Table( "mart_export (1)" ) << Subset(
Selected Rows( 0 ),
Rows(
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
39, 40, 41, 42, 43, 44, 45, 46, 47, 48]
),
columns( :Fruit, :Vegetable )
)
),
New Script(
"Concatenate vegetables per fruits",
dt = Data Table( "Fruit vs Veggies" );
New Column( "Vegetable number",
Character,
"Nominal",
formula( Col Rank( :Vegetable, :Fruit ) )
);
Data Table( "Fruit vs Veggies" ) << Split(
Split By( :Vegetable number ),
Split( :Vegetable ),
Group( :Fruit ),
Output Table( "Strange fruits" ),
Sort by Column Property
);
Data Table( "Strange fruits" ) << New Column( "Vegggies_concat",
Character,
"Nominal",
formula(
:Name( "1" ) || ", " || :Name( "2" ) || ", " || :Name( "3" ) || ", " ||
:Name( "4" ) || ", " || :Name( "5" ) || ", " || :Name( "6" ) || ", " ||
:Name( "7" ) || ", " || :Name( "8" ) || ", " || :Name( "9" ) || ", " ||
:Name( "10" ) || ", " || :Name( "11" ) || ", " || :Name( "12" ) || ", "
|| :Name( "13" ) || ", " || :Name( "14" ) || ", " || :Name( "15" ) ||
", " || :Name( "16" ) || ", " || :Name( "17" ) || ", " || :Name( "18" )
|| ", " || :Name( "19" ) || ", " || :Name( "20" ) || ", " ||
:Name( "21" ) || ", " || :Name( "22" ) || ", " || :Name( "23" ) || ", "
|| :Name( "24" ) || ", " || :Name( "25" ) || ", " || :Name( "26" ) ||
", " || :Name( "27" )
)
);
Data Table( "Strange fruits" ) << Subset(
Output Table( "Strange fruits_clean" ),
All rows,
columns( :Fruit, :Vegggies_concat )
) << close window;
),
New Column( "Fruit",
Character,
"Nominal",
Set Values(
{"Polb", "Polb", "Polb", "Polb", "Polb", "Polb", "Polb", "Polb", "Polb",
"Polb", "Polb", "Polb", "Polb", "Polb", "Polb", "Polb", "Polb", "Polb",
"Polb", "Polb", "Polb", "Polb", "Polb", "Polb", "Polb", "Polb", "Polb",
"Chrnb2", "Chrnb2", "Chrnb2", "Chrnb2", "Chrnb2", "Chrnb2", "Chrnb2",
"Chrnb2", "Chrnb2", "Chrnb2", "Chrnb2", "Chrnb2", "Chrnb2", "Chrnb2",
"Chrnb2", "Chrnb2", "Chrnb2", "Chrnb2", "Chrnb2", "Chrnb2", "Chrnb2"}
)
),
New Column( "Vegetable",
Character,
"Nominal",
Set Values(
{"nuclear chromosome", "cellular_component", "intracellular", "cell",
"nucleus", "chromosome", "organelle", "immune system process",
"biological_process", "anatomical structure development",
"DNA metabolic process", "cellular nitrogen compound metabolic process",
"molecular_function", "cytoplasm", "cytoskeleton", "DNA binding",
"nucleotidyltransferase activity", "biosynthetic process",
"response to stress", "cell death", "signal transduction",
"cytoskeletal protein binding", "lyase activity", "enzyme binding",
"homeostatic process", "ion binding", "protein complex",
"cellular component assembly",
"cellular nitrogen compound metabolic process", "transmembrane transport",
"ion binding", "cell proliferation", "immune system process",
"nervous system process", "response to stress", "cell-cell signaling",
"molecular_function", "cell", "cell morphogenesis", "biological_process",
"anatomical structure development", "cell differentiation", "transport",
"signal transduction", "plasma membrane", "cellular_component",
"signal transducer activity", "transmembrane transporter activity"}
)
),
New Column( "Vegetable number",
Numeric,
"Nominal",
Format( "Best", 9 ),
Formula( Col Rank( :Vegetable, :Fruit ) )
)
)