はい、可変数の野菜はこれをより複雑にします。 数式ではなく、スクリプトで連結の値を作成する方がおそらく簡単です。
このバージョンのスクリプトを見て、どのように実行するかを確認してください。
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 ) )
)
)