I have received a field with XY coordinates that have a decimal as a comma, but I cannot correctly open this file in R.
Here is how my data should look like - note comma as decimal indicator in y coordinates:
"OBJECTID";"x_coord";"y_coord"
"1";"664936,3059";"5582773,2319" # comma as separator
"2";"604996,5803";"5471445,4964"
"3";"772846,82";"5353980,45"
"4";"552181,8639";"5535271,7626"
"5";"604022,9011";"5470134,0649"
But, specifying the dec = ','
in read.csv
just reads it as a normal values:
xy <- read.delim(paste(path, "test_decimals2.txt", sep = '/'),
sep = '\t', dec = ",",skip = 0)
OBJECTID x_coord y_coord
1 1 6649363059 55827732319 # not a comma separator anymore
2 2 6049965803 54714454964
3 3 77284682 535398045
4 4 5521818639 55352717626
5 5 6040229011 54701340649
I have tried to convert the data to txt, etc. but still have the same problem. Do someone know how to make sure that dec = ','
will work correctly? Thank you!
(coordintaes are in UTM, that's why they look a bit weird)
I copied the data into a txt file and this worked just fine for me:
read.csv2("test_decimals2.txt")
Out:
OBJECTID x_coord y_coord
1 1 664936.3 5582773
2 2 604996.6 5471445
3 3 772846.8 5353980
4 4 552181.9 5535272
5 5 604022.9 5470134