您好,有什麼方法可以保留保存為 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 中的絕對值,這可能會在您上傳數據時提供幫助。但這兩者都會降低數據的某些精度。