为什么as.numeric函数在R中不能正常工作? [英] why as.numeric function in R doesn't work properly?
问题描述
我有这两个字符和as.numeric函数不能为他们工作相同。任何人都可以帮我解释为什么会发生这种情况?
p> a =27
as.numeric(a)
[1] 27.00000000000000000000
a =193381411288395777
as.numeric (a)
[1] 193381411288395776.0000
在第二种情况下,最后一位不是7而是6。基本上,as.numeric函数从第二种情况下的数字减少1个单位。
任何帮助是值得赞赏的。
使用 int64
包:
library(int64)
> as.int64(193381411288395777)
[1] 193381411288395777
I have these two characters and the "as.numeric" function doesn't work same for them. Can anyone help me why this is happening?
options(digits=22)
a="27"
as.numeric(a)
[1] 27.00000000000000000000
a="193381411288395777"
as.numeric(a)
[1] 193381411288395776.0000
It can be seen that in the second case the last digit is not "7" and it is "6". Basically the "as.numeric" function decreases 1 unit from the number in the second case.
Any help is appreciated.
Use the int64
package:
library(int64)
> as.int64("193381411288395777")
[1] 193381411288395777
这篇关于为什么as.numeric函数在R中不能正常工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!