My dataset assembles some geographic coordinates, as can be seen below:
dput(head(data))
structure(list(Latitude = c(-25.600992, -22.996431, -22.954634,
-12.983684, -22.990209, -22.955409), Longitude = c(-48.38602,
-43.25945, -43.062178, -38.520737, -43.191247, -43.174349)), row.names = c(NA,
6L), class = "data.frame")
I imported the above data into R, and I ran the following commands, in order to identify the country names based on latitudes and longitudes:
setwd(choose.dir())
data <- read.table("Coordinates.txt", h = T, sep = "\t")
library(maps)
data$Country <- map.where(database = "world", data$Longitude, data$Latitude)
However, in the new dataset, the Country column, instead of showing the country names, showed only NAs:
dput(head(data))
structure(list(Latitude = c(-25.600992, -22.996431, -22.954634,
-12.983684, -22.990209, -22.955409), Longitude = c(-48.38602,
-43.25945, -43.062178, -38.520737, -43.191247, -43.174349), Country = c(NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_, NA_character_
)), row.names = c(NA, 6L), class = "data.frame")
How could I solve this problem in order to get the country names from the coordinates I have?