您好,有什么方法可以保留保存为 Excel 的 JMP 表中的四舍五入小数位数吗? (.xls)
(Windows 10/JMP 12.2)
例如:dt<
在这种情况下,JMP 表的格式为 1 个四舍五入的小数位(例如 59.2),但生成的 Excel 表显示所有小数位(例如 59.21546)。Excel 单元格颜色格式看起来确实很棒,并且与 JMP 表格匹配得很好。
我想知道我是否需要以某种方式实际删除小数? (不是舍入,而是删除)如果是这样,这样做的好方法是什么?干杯,DJ
如果您需要在脚本或大表中执行此操作,这里是 Jim 关于使用 Round() 的建议的粗略实现,可能会让您入门。
Names default to here( 1);
//Open a table and set a column width
dt = Open( "$Sample_data/iris.jmp" );
Column( dt, 2 ) << Format( "Fixed Dec", 10, 0 );
//Make a copy of the table
dt2 = dt << Subset( All rows, Selected columns only( 0 ) );
//for each column
cols = dt2 << Get Column Names;
for( i = 1, i <= N Items( cols ), i++,
//Get the format of the column and convert it to a list
frmt = Column( dt2, cols[i] ) << Get Format;
frmt = Parse("{" || Regex(char(name expr(frmt)), "Format\((.*)\)", "\1") || "}");
//if formatted as a fixed decimal
if(frmt[1] == "Fixed Dec",
//Set the actual value to the rounded number
Column( dt2, cols[i] ) << Set Values(
Round(
Column( dt2, cols[i] ) << Get Values,
frmt[3]
)
)
)
);
//Save the table and open the temp files
dt2 << Save( "$Temp/mytable.xls", xls );
Open( "$Temp" );
//close the copied table
dt2 << Close Window;您可以使用 Format() 或 Round() 函数截断 JMP 中的绝对值,这可能会在您上传数据时提供帮助。但这两者都会降低数据的某些精度。