作者gsuper (统计的巴比伦塔)
看板Statistics
标题[程式] R的数字处理
时间Tue Aug 3 17:57:17 2010
------------------------------------------------------------------------
[软体程式类别]:
R
[程式问题]:
资料处理
[软体熟悉度]:
请把以下不需要的部份删除
中(3个月到1年)
[问题叙述]:
请问如何将
1.125600e+04
转换成
11256.00
因为我发现
R的一些函式会将 1.125600e+04 误认成字串
比方说 tapply()
我观察的结果
若一个 column 内 , 最大值与最小值差 10000 倍以上的时候 (含小数点)
会自动表示成 e+04
请问要怎麽把那个 e+04 去掉?
诚心请教
--
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.113.239.247
※ 编辑: gsuper 来自: 140.113.239.247 (08/03 17:58)
※ 编辑: gsuper 来自: 140.113.239.247 (08/03 18:03)
1F:推 bugle:?format 08/03 18:26
2F:推 Wush978:round? 08/03 19:57
round() 不行
format() 我试了一下也没找到要怎麽搞
我是拿以下这一串去测试
c(0.01,0.1,1,10,100)
※ 编辑: gsuper 来自: 140.113.239.247 (08/03 20:07)
3F:→ diplazium:照你的例子,format(#your no.#, science=F, nsmall=2) 08/03 20:47
> format(c(0.01,0.1,1,10,100), scientific=F, nsmall=2)
[1] " 0.01" " 0.10" " 1.00" " 10.00" "100.00"
> as.numeric(format(c(0.01,0.1,1,10,100), scientific=F, nsmall=2))
[1] 1e-02 1e-01 1e+00 1e+01 1e+02
> as.factor(format(c(0.01,0.1,1,10,100), scientific=F, nsmall=2))
[1] 0.01 0.10 1.00 10.00 100.00
Levels: 0.01 0.10 1.00 10.00 100.00
※ 编辑: gsuper 来自: 140.113.239.247 (08/03 21:11)
4F:推 memphis:formatC(1.125600e+04, format="d") 08/04 10:34
> formatC(c(0.01,0.1,1,10,100),format="d",digits=2)
[1] "0" "0" "1" "10" "100"
> formatC(c(0.01,0.1,1,10,100),format="fg",digits=2)
[1] "0.01" "0.1" " 1" " 10" "100"
转完以後都是字串
看起来还是只能用 as.factor 来转
※ 编辑: gsuper 来自: 140.113.239.247 (08/04 14:47)
※ 编辑: gsuper 来自: 140.113.239.247 (08/04 14:49)