出于某种原因,当我用科学计数法转换数字的字符列时,不会保留小数。
> str(output)
'data.frame': 213950 obs. of 2 variables:
$ ColA : chr ".3370E+03" ".3375E+03" ".3380E+03" ".3385E+03" ...
$ ColB : chr ".4942E+00" ".5295E+00" ".5682E+00" ".6091E+00" ...
> output$ColA = as.numeric(output$ColA)
> str(output)
'data.frame': 213950 obs. of 2 variables:
$ ColA : num 337 338 338 338 339 ...
$ ColB : chr ".4942E+00" ".5295E+00" ".5682E+00" ".6091E+00" ...
我希望它读为:
$ ColA : num 337 337.5 338 338.5 ...
我尝试了this SO question的解决方案,但没有运气:
> options(digits=9)
> str(output)
'data.frame': 213950 obs. of 2 variables:
$ ColA : num 337 338 338 338 339 ...
$ ColB : chr ".4942E+00" ".5295E+00" ".5682E+00" ".6091E+00" ...
发生了什么事?