创建与列列表对应的值列表我正在创建一个可能在使用的许多数据表之一中遇到的潜在列名称列表,创建在打开的数据表中找到的实际列列表,然后尝试创建与以下内容相对应的值列表实际的列列表。但是,当我运行以下代码时,它会从列表中第一列中获取我循环遍历的所有列的值。此代码生成列表 = {13.975, 13.975} 而不是 {13.975, 105}。我为此尝试了各种迭代,但无法获得正确的值。任何建议将不胜感激。
Clear Log();
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\Big Class.jmp" );
dt_col_name_list = dt << Get Column Names( String );
dtsum = dt << Summary(
Mean( Eval( dt_col_name_list ) ),
Freq( "None" ),
Weight( "None" ),
statistics column name format( "column" )
);
// Potential column name list
pot_col_list = {"age", "mass", "height", "length" };
dtsum_col_name_list = dtsum << Get Column Names( String );
show(dtsum_col_name_list);
// Create empty list to hold names of the those measurement variables found in data table
act_col_list = {};
col_list_cnt = {};
// Run through data table column names and put those that match measurement variable list into new list
For( i = 1, i <= N Items( pot_col_list ), i++,
If( Contains( dtsum_col_name_list, pot_col_list[i] ),
Insert Into( act_col_list, pot_col_list[i] );
Insert Into( col_list_cnt, dtsum:pot_col_list[1,i] );
)
);
Show( col_list_cnt );回复:创建与列列表相对应的值列表txnelson做到了,
感谢您查看并帮助纠正我的语法错误。
回复:创建与列列表相对应的值列表用于从 pot_col_list 获取值的引用无效,请参阅下文以了解似乎有效的更正
names default to here(1);
Clear Log();
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\Big Class.jmp" );
dt_col_name_list = dt << Get Column Names( String );
dtsum = dt << Summary(
Mean( Eval( dt_col_name_list ) ),
Freq( "None" ),
Weight( "None" ),
statistics column name format( "column" )
);
// Potential column name list
pot_col_list = {"age", "mass", "height", "length" };
dtsum_col_name_list = dtsum << Get Column Names( String );
show(dtsum_col_name_list);
// Create empty list to hold names of the those measurement variables found in data table
act_col_list = {};
col_list_cnt = {};
// Run through data table column names and put those that match measurement variable list into new list
For( i = 1, i <= N Items( pot_col_list ), i++,
If( Contains( dtsum_col_name_list, pot_col_list[i] ),
Insert Into( act_col_list, pot_col_list[i] );
Insert Into( col_list_cnt, column(dtsum,pot_col_list[i])[1] );
)
);
Show( col_list_cnt );