Title: ‘Assignment 0’ Author: “Cem Soylu” Date: “2022-08-17” Output: html_document

Chapter 1

We have taken our first few steps into Spatial Analytics. For this discussion we will share a simple map visualization in R.

Download libraries

library(janitor)
library(tidyr)
library(tidyverse)
library(rworldmap)
populationData <- population %>%
  filter(year==2013)

joinData <- joinCountryData2Map( populationData,
                                 joinCode = "NAME",
                                 nameJoinColumn = "country")
## 208 codes from your data successfully matched countries in the map
## 9 codes from your data failed to match with a country code in the map
## 35 codes from the map weren't represented in your data

Plot the population in the world

theMap <- mapCountryData( joinData, nameColumnToPlot="population", addLegend=FALSE )
do.call( addMapLegend, c(theMap, legendWidth=1, legendMar = 2))

Modify the color to investigate which countries have the least and the most population.

theMap_smallPop <- mapCountryData( joinData, nameColumnToPlot="population", catMethod = c(1344,10000000), addLegend=FALSE )

theMap_ownNr <- mapCountryData( joinData, nameColumnToPlot="population", catMethod = c(150000000, 2000000000), addLegend=FALSE )

Zoom in to see population in a particular region: Asia

mapRegion = "Asia"
theMap_europe <- mapCountryData( joinData, nameColumnToPlot="population", mapRegion = "Asia", addLegend=FALSE )

This map shows more how the population is distributed.

data(gridExData)
mapGriddedData(gridExData)