0

I have wide format data in a .dta file, merged by 'ID' that's numeric. When I look at the preview on R, the data are fine. However, when I read it into R and open it using View(), all the numeric variables in the data frame have been changed to '8.00000e+01', '6.039095e+09' etc.

I've never encountered this problem while importing datasets before. Can someone explain how to change it back and why this is happening?

Rnovice
  • 59
  • 6
  • On the basis of what you've told us so far, no we can't. You maximise your chance of getting a useful answer if you provide a minimum reproducible example. [This post](https://stackoverflow.com/help/minimal-reproducible-example) may help. How are you reading the file into R? Are the "numeric" variables now of character type or is it simply that their display format has changed? – Limey May 24 '21 at 06:40
  • Run `options(scipen = 999)` in the console. – Ronak Shah May 24 '21 at 06:45

1 Answers1

0

Possible duplicate here: How to disable scientific notation?

In a nutshell: if you want to change only one column, just change scipen to 999, change value to character type, and revert back.

PS. I assume that you don't have to do calculation at the ID column since it is unique.

df <- data.frame(x = 10000000000, y = 200000000)
df
      x     y
1 1e+10 2e+08

options(scipen = 999)
df
            x         y
1 10000000000 200000000
df$x <- as.character(df$x)

options(scipen = 0)
df
            x     y
1 10000000000 2e+08
Pete Kittinun
  • 593
  • 3
  • 15