Iteratives Erstellen von Spalten, die alle Permutationen der Subtraktion aus einer anfänglichen Spaltenliste enthaltenIch habe eine Liste mit Spalten und muss mit jeder Permutation der Differenz zwischen den aufgelisteten Spalten eine neue Spaltenreihe erstellen. Die Anzahl der Spalten in der Liste kann variieren und das nicht-iterative Beispiel unten umfasst 3 Spalten (12 bis 14).
Current Data Table() << New Column(Head Name( As Namespace( Column( 12 ) ) )||" - "||Head Name( As Namespace( Column( 13 ) ) )||" HSD Threshold Matrix", Numeric, "Continuous", Format("Best", 10), Formula(Col Maximum(If(Contains(:Level, Head Name(As Namespace(Column(13))), 1), As Column(12)), :Group, :Size)));
Current Data Table() << New Column(Head Name( As Namespace( Column( 12 ) ) )||" - "||Head Name( As Namespace( Column( 14 ) ) )||" HSD Threshold Matrix", Numeric, "Continuous", Format("Best", 10), Formula(Col Maximum(If(Contains(:Level, Head Name(As Namespace(Column(14))), 1), As Column(12)), :Group, :Size)));
Current Data Table() << New Column(Head Name( As Namespace( Column( 13 ) ) )||" - "||Head Name( As Namespace( Column( 14 ) ) )||" HSD Threshold Matrix", Numeric, "Continuous", Format("Best", 10), Formula(Col Maximum(If(Contains(:Level, Head Name(As Namespace(Column(14))), 1), As Column(13)), :Group, :Size)));
Automatisierung und SkriptingBetreff: Iteratives Erstellen von Spalten, die alle Permutationen der Subtraktion aus einer anfänglichen Spaltenliste enthaltenSie können beispielsweise NChooseK Matrix() verwenden, um die Kombinationen (oder DoE) zu erstellen.
Names Default To Here(1);
mylist = {12, 13, 14};
possible_group_idx = NChooseK Matrix(3,2);
my_groups = Transform Each({idx}, possible_group_idx,
mylist[idx]
);
[12 13, 12 14, 13 14]
Betreff: Iteratives Erstellen von Spalten, die alle Permutationen der Subtraktion aus einer anfänglichen Spaltenliste enthaltenJarmo
Danke, sieht aus, als würde es funktionieren. Ich hatte noch keine Zeit, die Details zu studieren, frage mich aber, ob es ein Beispiel dafür gibt, wie es eingesetzt werden kann?
Betreff: Iteratives Erstellen von Spalten, die alle Permutationen der Subtraktion aus einer anfänglichen Spaltenliste enthaltenFühren Sie eine Schleife durch die Matrix (oder wandeln Sie sie in eine Liste von Listen um) und erstellen Sie dabei die Spalten.
Betreff: Iteratives Erstellen von Spalten, die alle Permutationen der Subtraktion aus einer anfänglichen Spaltenliste enthaltenIch bin nicht sicher, ob Sie das gemeint haben, aber ich habe hier etwas gefunden, das funktioniert. Und was noch besser ist: Es ist nicht auf Spaltennummern angewiesen.
Names Default to Here(1);
dt = Current Data Table();
//Select X Variable ____________________________________________________________________________________________________________________________________________
cdb = Column Dialog("Add continuous variables you want to plot as X" ,
colxx = ColList( "X", Min Col( 1 ) ),
);
show(cdb);
Eval List(cdb[1::N Items(cdb)-1]);
Summarize(dt, uniqNames = by(colxx[1]));
Show(uniqNames);
Num = NItems(uniqNames);
For( k = 1, k <= N Items( uniqNames ), k++,
// Loop through all columns finding non NA values
For( i = 2, i <= N Items( uniqNames ), i++,
if (i > k, Current Data Table() << New Column(Char(uniqNames[k])||" - "||Char(uniqNames[i])||" Matrix", Numeric, "Continuous", Format("Best", 10), Formula(Col Maximum(If(Contains(:Level, Char(uniqNames[i]), 1), As Column(uniqNames[k])), :Group, :Size)));
)
)
)
;
Gelöst: Spaltenwerte mit Schleife abrufen - JMP-Benutzer-Community
Betreff: Iteratives Erstellen von Spalten, die alle Permutationen der Subtraktion aus einer anfänglichen Spaltenliste enthaltenNames Default To Here(1);
dt = Open("$SAMPLE_DATA/Cities.jmp");
mycols = {"OZONE", "CO", "SO2", "NO", "PM10"};
possible_group_idx = NChooseK Matrix(N Items(mycols), 2);
my_groups = Transform Each({idx}, As List(possible_group_idx), Output("List"),
mycols[idx]
);
For Each({cols}, my_groups,
Eval(Substitute(
Expr(dt << New Column(cols[1] ||"_"||cols[2], Numeric, Continuous,
Formula(_col1_ + _col2_)
)),
Expr(_col1_), Name Expr(AsColumn(dt, cols[1])),
Expr(_col2_), Name Expr(AsColumn(dt, cols[2]))
));
);
Write();