1

I have a large dataset of 100.000 obersavtions with data for longitude and latitude as well. Some of them are of 6, 7 or 8 digits length without any separation such as a dot. E.g: 12984582 or 8430766. They need to be transformed to 12.984582 and 8.430766. Already tried to solve this problem with gsub/sub but they seem not to work.

Phil
  • 7,287
  • 3
  • 36
  • 66
Lioozy
  • 11
  • 1

1 Answers1

1

You can use format with big.mark. Learned here Format number in R with both comma thousands separator and specified decimals

# example dataset

x <- 100000:100100
df <- data.frame(x)

format(round(as.numeric(df$x), 1), big.mark=",") 
TarJae
  • 72,363
  • 6
  • 19
  • 66