rlatitude-longitudecolumn-types

How can I change the cell format from ":" to lat and long (degree, minute, second) type


The data has 34773 rows and 28 column. One of these columns contains the latitude and the other longitude information for each row. But these coordinates are supposed to be separated in degrees minutes seconds (° ' ''), but instead they are separated by colons. How can I change this?

Relevant columns


Solution

  • Hi enesson,

    Be careful because you haven't read the names of the variables as its first line, that is, the header parameter. So, you will have to adapt the second line of this code to your data.

    As you can see here, I used the separate function according to this post. It may be useful for you!

    library(tidyr)
    df <- read.csv("your_data.csv", header = TRUE, sep = ";")
    df1 <- separate(data = df, col = KUZEY, into = c("lat_degrees", "lat_minutes", "lat_seconds"), sep = ":")
    df2 <- separate(data = df1, col = DOGU, into = c("lon_degrees", "lon_minutes", "lon_seconds"), sep = ":")
    

    I hope this helps you 😃