从用户输入定义列公式嗨,
我试图从用户输入定义一个新的列公式。 我尝试过Eval(),Eval Insert()和Parse()的不同组合,但没有成功。 输入可以是列或列列表,也可以是标量。 以下是一个最小的例子。 有什么建议?我正在使用JMP14,但我希望该解决方案适用于JMP12及更高版本。
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
// Define new column.
dt << New Column( "Mean for Each Age and Sex Group",
Formula( Col Mean( :height, :age, :sex ) )
);
// Define user input.
a = 2;
c1 = :height;
c2 = {:age, :sex};
// Define new column from user input.
dt << New Column( "Mean for Each Age and Sex Group 2",
Formula( Col Mean( a * c1, c2 ) )
);Re:从用户输入定义列公式我不完全确定在用户输入的新创建的列中你想要什么公式,但看看这个 JSL Cookbook文章 ,它给出了构建新列公式的几种不同方法的示例。
Re:从用户输入定义列公式谢谢!非常有用的页面。
Re:从用户输入定义列公式在...的帮助下 @ih 的输入,这是一个有兴趣的人的解决方案...
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
// Define user input.
a = 2;
c1 = Column( "height" );
c2 = {:age, :sex};
// Define new column from user input.
input = Concat( "As Column( \!"", c1 << Get Name, "\!" )" );
If( N Items( c2 ) > 0,
For( i = 1, i <= N Items( c2 ), i++,
input = Insert( input, Concat( ", ", "As Column( \!"", Char( c2[i] ), "\!" )" ) )
)
);
Eval( Parse( Eval Insert( "dt << New Column( \!"Mean for Each Age and Sex Group 2\!", Formula( ^a^ * Col Mean( ^input^ ) ) )" ) ) );