##maps

setwd("D:/AVRespaldo/Personal/Especializacion/SEM 2/Comunicacion de los analisis")
globeMap <- read.csv("globeMap.csv")
# show the structure of the dataframe
str(globeMap)
## 'data.frame':    104410 obs. of  13 variables:
##  $ X                        : int  1 2 3 4 5 6 7 8 9 10 ...
##  $ long                     : num  -69.9 -69.9 -69.9 -70 -70.1 ...
##  $ lat                      : num  12.5 12.4 12.4 12.5 12.5 ...
##  $ group                    : int  1 1 1 1 1 1 1 1 1 1 ...
##  $ order                    : int  1 2 3 4 5 6 7 8 9 10 ...
##  $ region                   : Factor w/ 251 levels "Afghanistan",..: 11 11 11 11 11 11 11 11 11 11 ...
##  $ subregion                : Factor w/ 1009 levels "'Eua"," British",..: NA NA NA NA NA NA NA NA NA NA ...
##  $ Three_Letter_Country_Code: Factor w/ 178 levels "AFG","AGO","ALB",..: NA NA NA NA NA NA NA NA NA NA ...
##  $ Continent_Name           : Factor w/ 6 levels "Africa","Asia",..: NA NA NA NA NA NA NA NA NA NA ...
##  $ Continent_Code           : Factor w/ 5 levels "AF","AS","EU",..: NA NA NA NA NA NA NA NA NA NA ...
##  $ Country_Name             : Factor w/ 178 levels "Afghanistan, Islamic Republic of",..: NA NA NA NA NA NA NA NA NA NA ...
##  $ Two_Letter_Country_Code  : Factor w/ 177 levels "AE","AF","AG",..: NA NA NA NA NA NA NA NA NA NA ...
##  $ Country_Number           : int  NA NA NA NA NA NA NA NA NA NA ...
##mapa
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 3.5.3
mapa <- ggplot(globeMap, aes(x=long, y=lat, group = as.factor(group)))
# add geometry
mapa <- mapa + geom_polygon(aes(fill=Continent_Name, color=Continent_Name))
# add color palettes
mapa <- mapa + scale_fill_viridis_d()
mapa <- mapa + labs(title = "Countries outlined by region", subtitle = "Using a mercator projection", caption = "Dataset retrieved from native ggplot map", x = "Longitude", y= "Latitude")
# add margins
mapa <- mapa + theme_bw()
# plot the map
mapa