问题
How can I read data in scientific notation (D+) format into R?
e.g.
-0.416932D+01, -0.412300D+02
回答1:
Solution using stringr
package:
library(stringr)
x <- c("-0.416932D+03")
as.numeric(str_replace(x, "D", "e"))
[1] -416.932
If you prefer not to use external packages, you can use the gsub
function from the base package:
as.numeric(gsub("D","e",x))
来源:https://stackoverflow.com/questions/29166012/reading-scientific-notation-d