hello and welcome to this four series lecture video
on geographic plots in R
In this video we will creat
world map and US maps
and in the next one we'll use COVID data
to creat USA map followed by
USA map for each county
And then we will focus on only two states
And look at various different features available
In the package
We will make use of these libraries
Let's store world map data in 'w'
map_data
then we can say we want 'world' data
so this w has more then 99000 observation
and 6 variables and
first 2 columns are longitude and latitude
and then we have group order
and region is basically country
suppose i want to create a map for
three country let me store that
information in 'i' for Italy
's' for Spain, 'f' for France
so we are using region because
you see the countries are listed under
region
so now 'isf' have data for
this three countries
so we can now make a map using 'ggplot'
our data is in 'isf'
foe 'x' we are going to use
the name of the variable 'long'
for longitude
latitude and then we have to
use group
and then we can make use of
polygon geometric shape
so this gives us this map here
If we add fill and
region which are basically countries so we can get
this map with three different colors
if we want to indicate boundaries with a black colour
we can out black here
we can do this any number of countries
so for example if we want to do
India, China, Japan
so we can do that very easily
if the picture look like compressed or stretched
what we can do is we can add another line
with plus sign and say
coord_map
polyconic
so anyway you look at it it will not be like
stretched or compressed
so let's store within 's'
states information from US and that
we can get simply by saying 'state'
so look inside you can see you have region
which contains names of different states
so lets use this code
that we created just now
and modify little bit
so we want 's' here
so let's get just basic map first
so this is the map we get
if we do fill region
and run
so you may notice that map is too small
because the entire space is occupied by
name of the states to avoide
that we can simply add one more line
guides and fill equals
False
so we get map for US with
all the states
in the next video we'll go over
USA map with COVID data