안녕하세요 여러분,
아래 의도한 대로 작동하는 코드가 있습니다. 그러나 문제는 코드 반복으로 인해 이론상 대체를 통한 for 루프가 코드 줄을 절약하는 기능을 할 수 있어야 하는 불필요하게 긴 500줄의 코드가 생성된다는 것입니다.
old win = New Window( "Old Win", vlis old = V List Box() );
df movies = Open("C:\Program Files\JMP\JMP\18\Samples\Data\Movies.jmp");
df action = df movies << Subset( Columns(), Rows(), Output Table Name( "df action" ));
Column( df action, "Rating" ) << Set Property( "Value Colors", {"R" = 0} );
color_or_not = 1;
df action << Select Where(
Or(
!Contains( :Type, "Action" ),
Contains( :Rating, "13" )
)
) << Exclude;
df action << Delete Rows;
action lbx = V List Box(
If(color_or_not == 1,
vc action = df action << Variability Chart(
Y( :Year ),
X( :Movie ),
Show Range Bars( 0 ),
Show Cell Means( 0 ),
Std Dev Chart( 0 ),
Points Jittered( 1 ),
Title( "Variability chart for Action" ),
SendToReport(
Dispatch(
{"Variability Chart for Signal"},
"2",
ScaleBox,
{Min( -50 ), Add Ref Line( 0, "Dotted", "Medium Light Gray", "", 1 ),
Add Ref Line( 1999, "Dotted", "Medium Light Green", "1999", 1 )}
),
Dispatch(
{""},
"Variability Chart",
FrameBox,
{Row Legend(
Rating,
Color( 1 ),
Color Theme( "" ),
Marker( 0 ),
Marker Theme( "" ),
Continuous Scale( 0 ),
Reverse Scale( 0 ),
Excluded Rows( 0 )
)}
);
);
);
,
vc action = df action << Variability Chart(
Y( :Year ),
X( :Movie ),
Show Range Bars( 0 ),
Show Cell Means( 0 ),
Std Dev Chart( 0 ),
Points Jittered( 1 ),
Title( "Variability chart for Action" ),
SendToReport(
Dispatch(
{"Variability Chart for Signal"},
"2",
ScaleBox,
{Min( -50 ), Add Ref Line( 0, "Dotted", "Medium Light Gray", "", 1 ),
Add Ref Line( 1999, "Dotted", "Medium Light Green", "1999", 1 )}
);
);
);
);
);
vlis old << Append( action lbx );
df comedy = df movies << Subset( Columns(), Rows(), Output Table Name( "df comedy" ));
Column( df comedy, "Rating" ) << Set Property( "Value Colors", {"R" = 0} );
df comedy << Select Where(
Or(
!Contains( :Type, "Comedy" ),
Contains( :Rating, "13" )
)
) << Exclude;
df comedy << Delete Rows;
comedy lbx = V List Box(
If(color_or_not == 1,
vc comedy = df comedy << Variability Chart(
Y( :Year ),
X( :Movie ),
Show Range Bars( 0 ),
Show Cell Means( 0 ),
Std Dev Chart( 0 ),
Points Jittered( 1 ),
Title( "Variability chart for Comedy" ),
SendToReport(
Dispatch(
{"Variability Chart for Signal"},
"2",
ScaleBox,
{Min( -50 ), Add Ref Line( 0, "Dotted", "Medium Light Gray", "", 1 ),
Add Ref Line( 2000, "Dotted", "Medium Light Green", "2000", 1 )}
),
Dispatch(
{""},
"Variability Chart",
FrameBox,
{Row Legend(
Rating,
Color( 1 ),
Color Theme( "" ),
Marker( 0 ),
Marker Theme( "" ),
Continuous Scale( 0 ),
Reverse Scale( 0 ),
Excluded Rows( 0 )
)}
);
);
);
,
vc comedy = df comedy << Variability Chart(
Y( :Movie ),
X( :Year ),
Show Range Bars( 0 ),
Show Cell Means( 0 ),
Std Dev Chart( 0 ),
Points Jittered( 1 ),
Title( "Variability chart for Comedy" ),
SendToReport(
Dispatch(
{"Variability Chart for Signal"},
"2",
ScaleBox,
{Min( -50 ), Add Ref Line( 0, "Dotted", "Medium Light Gray", "", 1 ),
Add Ref Line( 2000, "Dotted", "Medium Light Green", "2000", 1 )}
);
);
);
);
);
vlis old << Append( comedy lbx );
df family = df movies << Subset( Columns(), Rows(), Output Table Name( "df family" ));
Column( df family, "Rating" ) << Set Property( "Value Colors", {"R" = 0} );
df family << Select Where(
Or(
!Contains( :Type, "Family" ),
Contains( :Rating, "13" )
)
) << Exclude;
df family << Delete Rows;
family lbx = V List Box(
If(color_or_not == 1,
vc family = df family << Variability Chart(
Y( :Year ),
X( :Movie ),
Show Range Bars( 0 ),
Show Cell Means( 0 ),
Std Dev Chart( 0 ),
Points Jittered( 1 ),
Title( "Variability chart for Family" ),
SendToReport(
Dispatch(
{"Variability Chart for Signal"},
"2",
ScaleBox,
{Min( -50 ), Add Ref Line( 0, "Dotted", "Medium Light Gray", "", 1 ),
Add Ref Line( 1995, "Dotted", "Medium Light Green", "1995", 1 )}
),
Dispatch(
{""},
"Variability Chart",
FrameBox,
{Row Legend(
Rating,
Color( 1 ),
Color Theme( "" ),
Marker( 0 ),
Marker Theme( "" ),
Continuous Scale( 0 ),
Reverse Scale( 0 ),
Excluded Rows( 0 )
)}
);
);
);
,
vc family = df family << Variability Chart(
Y( :Movie ),
X( :Year ),
Show Range Bars( 0 ),
Show Cell Means( 0 ),
Std Dev Chart( 0 ),
Points Jittered( 1 ),
Title( "Variability chart for Family" ),
SendToReport(
Dispatch(
{"Variability Chart for Signal"},
"2",
ScaleBox,
{Min( -50 ), Add Ref Line( 0, "Dotted", "Medium Light Gray", "", 1 ),
Add Ref Line( 2000, "Dotted", "Medium Light Green", "2000", 1 )}
);
);
);
);
);
vlis old << Append( family lbx );이제 이 for 루프를 만들기 위해 표현식의 jmp 대체에 대한 이해를 사용하려고 시도했으며 로그에서 데이터 테이블이 적절하게 부분 집합되었음을 볼 수 있지만 위의 코드와 같이 V 목록 상자를 창에 추가할 수 없습니다. 문제없이 할 수 있습니다. for 루프가 위와 같이 작동하도록 도움을 주시면 대단히 감사하겠습니다. 감사해요!
Clear Globals();
Clear Log();
df movie = Open("C:\Program Files\JMP\JMP\18\Samples\Data\Movies.jmp");
color_or_not = 1;
df action = df movie << Subset( Columns(), Rows(), Output Table Name( "df action" ), Invisible );
df comedy = df movie << Subset( Columns(), Rows(), Output Table Name( "df comedy" ), Invisible );
df family = df movie << Subset( Columns(), Rows(), Output Table Name( "df family" ), Invisible );
new win = New Window( "New Win", vlis = V List Box() );
df list = {df action, df comedy, df family};
to remove one = {"Action", "Comedy", "Family"};
to remove two = {"13", "13", "13"};
names = {"Action", "Comedy", "Family"};
ref val = {1999, 2000, 1995};
ref line = {"1999", "2000", "1995"};
for (i = 1, i<=3, i++,
Eval(
Substitute(
Expr(
Column( _df list_ , "Rating" ) << Set Property( "Value Colors", {"R" = 0} );
_df list_ << Select Where(
Or(
!Contains( :"Type", _to remove one_ ),
Contains( :"Rating", _to remove two_ )
)
) << Exclude;
_df list_ << Delete Rows;
),
Expr( _df list_ ), df list[i],
Expr( _to remove one_ ), to remove one[i],
Expr( _to remove two_ ), to remove two[i],
);
);
If(color_or_not == 1,
Substitute(
Expr(
graph = V List Box(
vc = _df list_ << Variability Chart(
Y( :Year ),
X( :Movie ),
Show Range Bars( 0 ),
Show Cell Means( 0 ),
Std Dev Chart( 0 ),
Points Jittered( 1 ),
Title( "Variability chart for " || _names_ ),
SendToReport(
Dispatch(
{"Variability Chart for Signal"},
"2",
ScaleBox,
{Min( -50 ), Add Ref Line( 0, "Dotted", "Medium Light Gray", "", 1 ),
Add Ref Line( _ref val_ , "Dotted", "Medium Light Green", _ref line_ , 1 )}
),
Dispatch(
{""},
"Variability Chart",
FrameBox,
{Row Legend(
Rating,
Color( 1 ),
Color Theme( "" ),
Marker( 0 ),
Marker Theme( "" ),
Continuous Scale( 0 ),
Reverse Scale( 0 ),
Excluded Rows( 0 )
)}
);
);
);
);
vlis << Append( graph );
),
Expr( _df list_ ), df list[i],
Expr( _names_ ), names[i],
Expr( _ref val_ ), ref val[i],
Expr( _ref line_ ), ref line[i]
);
,
Substitute(
Expr(
graph = V List Box(
vc = _df list_ << Variability Chart(
Y( :Year ),
X( :Movie ),
Show Range Bars( 0 ),
Show Cell Means( 0 ),
Std Dev Chart( 0 ),
Points Jittered( 1 ),
Title( "Variability chart for " || _names_ ),
SendToReport(
Dispatch(
{"Variability Chart for Signal"},
"2",
ScaleBox,
{Min( -50 ), Add Ref Line( 0, "Dotted", "Medium Light Gray", "", 1 ),
Add Ref Line( _ref val_ , "Dotted", "Medium Light Green", _ref line_ , 1 )}
);
);
);
);
vlis << Append( graph );
),
Expr( _df list_ ), df list[i],
Expr( _names_ ), names[i],
Expr( _ref val_ ), ref val[i],
Expr( _ref line_ ), ref line[i]
);
);
);Eval(Substitute(Expr))) 처리에서 Eval() 함수를 생략했습니다.
Names Default To Here( 1 );
Clear Globals();
Clear Log();
df movie = Open( "$SAMPLE_DATA\Movies.jmp" );
color_or_not = 1;
df action = df movie << Subset( Columns(), Rows(), Output Table Name( "df action" ), Invisible );
df comedy = df movie << Subset( Columns(), Rows(), Output Table Name( "df comedy" ), Invisible );
df family = df movie << Subset( Columns(), Rows(), Output Table Name( "df family" ), Invisible );
new win = New Window( "New Win", vlis = V List Box() );
df list = {df action, df comedy, df family};
to remove one = {"Action", "Comedy", "Family"};
to remove two = {"13", "13", "13"};
names = {"Action", "Comedy", "Family"};
ref val = {1999, 2000, 1995};
ref line = {"1999", "2000", "1995"};
For( i = 1, i <= 3, i++,
Eval(
Substitute(
Expr(
Column( _df list_, "Rating" ) << Set Property( "Value Colors", {"R" = 0} );
_df list_ << Select Where(
Or( !Contains( :"Type", _to remove one_ ), Contains( :"Rating", _to remove two_ ) )
) << Exclude;
_df list_ << Delete Rows;
),
Expr( _df list_ ), df list[i],
Expr( _to remove one_ ), to remove one[i],
Expr( _to remove two_ ), to remove two[i],
)
);
If( color_or_not == 1,
Eval(
Substitute(
Expr(
graph = V List Box(
vc = _df list_ << Variability Chart(
Y( :Year ),
X( :Movie ),
Show Range Bars( 0 ),
Show Cell Means( 0 ),
Std Dev Chart( 0 ),
Points Jittered( 1 ),
Title( "Variability chart for " || _names_ ),
SendToReport(
Dispatch( {"Variability Chart for Year"}, "2", ScaleBox,
{Min( -50 ), Add Ref Line( 0, "Dotted", "Medium Light Gray", "", 1 ),
Add Ref Line(
_ref val_, "Dotted", "Medium Light Green", _ref line_, 1
)}
),
Dispatch( {""}, "Variability Chart", FrameBox,
{Row Legend(
Rating,
Color( 1 ),
Color Theme( "" ),
Marker( 0 ),
Marker Theme( "" ),
Continuous Scale( 0 ),
Reverse Scale( 0 ),
Excluded Rows( 0 )
)}
)
)
)
);
Show( "at vlis" );
vlis << Append( graph );
),
Expr( _df list_ ), df list[i],
Expr( _names_ ), names[i],
Expr( _ref val_ ), ref val[i],
Expr( _ref line_ ), ref line[i]
)
)
,
Eval(
Substitute(
Expr(
graph = V List Box(
vc = _df list_ << Variability Chart(
Y( :Year ),
X( :Movie ),
Show Range Bars( 0 ),
Show Cell Means( 0 ),
Std Dev Chart( 0 ),
Points Jittered( 1 ),
Title( "Variability chart for " || _names_ ),
SendToReport(
Dispatch( {"Variability Chart for Year"}, "2", ScaleBox,
{Min( -50 ), Add Ref Line( 0, "Dotted", "Medium Light Gray", "", 1 ),
Add Ref Line(
_ref val_, "Dotted", "Medium Light Green", _ref line_, 1
)}
)
)
)
);
vlis << Append( graph );
),
Expr( _df list_ ), df list[i],
Expr( _names_ ), names[i],
Expr( _ref val_ ), ref val[i],
Expr( _ref line_ ), ref line[i]
)
)
);
);