列の反復列のリストを反復処理するスクリプトを作成中ですが、問題が発生しました。列参照を「:Technology Default」の形式で出力できるようにする必要がありますが、調べたすべてのメソッドで「Column("Technology Default")」が出力されます。オンラインで調べたところ、必要な参照は「列参照」であるように見えますが、取得されるのは「列オブジェクト参照」です。目的のことを簡単な方法で実行できるでしょうか?
自動化とスクリプトRe: 列の反復処理何をしようとしていますか? AsColumn() と Column() (場合によっては Eval()) を使用できます (その形式では As Column() が通常は機能しますが、式で使用する必要がある場合があります)。
編集:
いくつかのリンク:
たとえば、数式でその形式を取得したい場合は、EvalExpr + Name Expr + As Columnが通常私が最初に使用する方法です。
Names Default To Here(1);
dt = open("$SAMPLE_DATA/Big Class.jmp");
colname = "height";
Eval(EvalExpr(
dt << New Column(Eval Insert("^colname^*^colname^"), Numeric, Continuous, Formula(
Expr(Name Expr(AsColumn(dt, colname))) * Expr(Name Expr(AsColumn(dt, colname)))
));
));
Re: 列の反復処理私の最終目標は、新しい列の数式で使用できるものを用意することです。どうやら、数式は「:Column」として指定された場合にのみ列を認識します。とにかく、このリンクで見つけた情報の助けを借りて。
解決済み: 文字列内の二重引用符を置き換える方法 - JMP ユーザー コミュニティ
目標を達成するために、私は強引な方法を思いつきました。エレガントではありませんが、うまく機能しているようです。これをより正式に行う方法についての提案はまだ受け付けています。
さよなら
スパナヘッド
dt = Current Data Table();
lst = dt << Get Column Names(string);
For(i=1,i<=NItems(lst),i++,
colName = lst[i];
col = Column(colName);
Colstring = (":"||colName);
Colref = Parse( Eval Insert(Colstring));
Show(Colref););Re: 列の反復処理JMP では、管理が面倒すぎるため、通常はそのような列参照は扱いません -> 列名の文字列を使用し、必要に応じて Column()、As Column()、Eval()、または NameExpr(AsColumn()) で使用します (何らかの理由で列参照 (Column("something"))を使用する必要がある場合は、必要に応じて << Get Name を使用して文字列に変換します)。
Names Default To Here(1);
dt = open("$SAMPLE_DATA/Big Class.jmp");
col1 = "height";
col2 = "weight";
<BR />// Good way but can be (sometimes) difficult to read
Eval(EvalExpr(
dt << New Column("mycol1", Numeric, Continuous, Formula(
Expr(Name Expr(AsColumn(dt, col1))) * Expr(Name Expr(AsColumn(dt, col2)))
))
));
<BR />// might be easier to read
Eval(Substitute(
Expr(dt << New Column("mycol2", Numeric, Continuous, Formula(
_firstcol_ * _secondcol_
))),
Expr(_firstcol_), Name Expr(AsColumn(dt, col1)),
Expr(_secondcol_), Name Expr(AsColumn(dt, col2))
));
// "reusable"
ref1 = Name Expr(AsColumn(dt, col1)); // this will return :height BUT you will generally still need Name Expr() to use it
ref2 = Name Expr(AsColumn(dt, col2));
// wont work, because ref1 will get evaluated for "current" row
Eval(EvalExpr(
dt << New Column("mycol3", Numeric, Continuous, Formula(
Expr(ref1) * Expr(ref2)
))
));
// will work
Eval(EvalExpr(
dt << New Column("mycol3", Numeric, Continuous, Formula(
Expr(Name Expr(ref1)) * Expr(Name Expr(ref2))
))
));
もしあなたがただ
dt << New Column("mycol4", Numeric, Continuous, Formula(
ref1 * ref2
));
ref1*ref2のような式になります。これらは式に評価されないためです。

その他のリンク:
Re: 列の反復処理間違ったことを言っているかもしれませんが、問題は数式で列参照を使用していることにあるようです。数式を作成するときにそれらの参照を解決する必要があります。Jarmo の例にはまさにそれを実行する例が示されていますが、少しわかりにくいかもしれません。以下は、非常に簡単な例で問題と解決策を説明する試みです。
// Here is a sample script, that creates a new data table
// with 2 columns, and what we want to do, is to simply
// put the value 1 into column c1, and a 2 into column c2
// In the first example, it is done by simply running a
// for() loop and taking the index variable, "i" and using it in
// the formula and squaring it's value.
Names Default To Here( 1 );
dt = New Table( "Example" );
dt<< add rows(1);
For( i = 1, i <= 2, i++,
dt << New Column( "c" || Char( i ),
formula( i^2 )
)
);
// When each column was created, it used the value of i at that
// time within the formula. Thus, for c1, the value of i was 1,
// and for c2 it was 4.
// So now, if we rerun the formulas, it will take the value of
// i at the time of rerunning each formula.
wait(5);
dt<<RERUN formulas=""></RERUN>
<P>これが役に立つことを願っています</P>Re: 列の反復処理「力ずく」の代わりに
Colstring = (":"||colName);
Colref = Parse( Eval Insert(Colstring));よりエレガントな方法は次のとおりです。
Colref= Name Expr (As Column(colName))
-> @jthiの返信を参照してください。
すでに多くのユーザーに役立っています: JMP での式の処理: ヒントとトラップドア
ところで:
この例では、 列名を取得するを介してコルレフ( s) を直接取得できます。STRING 引数を削除するだけです。
先頭に「:」はありませんが、これは単なる装飾です:)
dt = Current Data Table();
lst = dt << Get Column Names();
For( i = 1, i <= N Items( lst ), i++,
Show( lst[i] );
Show( lst[i][5] );
);
Re: 列の反復処理列名の先頭に「:」を付けたい場合は、次のトリックを使用できます:
それぞれの名前を尋ねます。
columnNames = current data table() << Get Column Names;
for (i=1, i<= Nitems(columnNames),i++,columnNames[i]<< get name() );
show(columnNames) // -> column names with leading ":"