1、查看默认值
> getOption("digits") [1] 7 ## 默认显示是7位
2、测试
> a = 1.12345 > a ## a为6位,正常显示 [1] 1.12345 > a = 1.123456 > a ## a为7位, 正常显示 [1] 1.123456 > a = 1.1234567 > a ## a为8位,仅能显示7位,且四舍五入 [1] 1.123457 > a = 1.12345678 > a ## a为9位, 仅能显示7位, 四舍五入 [1] 1.123457
3、设置指定位数
> getOption("digits") [1] 7 > options(digits = 10) ## 设置位数为10 > getOption("digits") [1] 10 > a = 1.12345678 > a [1] 1.12345678 > a = 1.123456789 > a [1] 1.123456789 > a = 1.1234567891 ## a为11位, 只能显示10位 > a [1] 1.123456789
> options(digits = 2) ## 设置位数为2 > a = 1.1 > a [1] 1.1 > a = 1.12 > a ## 只能显示2位 [1] 1.1 > a = 1.123 > a [1] 1.1 > a = 1.1567 > a ## 只能显示两位,且四舍五入 [1] 1.2