Project Part 1

Population density

  1. I downloaded population density data form Our World in Data. I selected this data because i am interested in how our planet, and its people.

  2. This is the link to the data.

  3. The following code chunk loads the package iw ill use to read in and prepare the data for analysis.

  1. Read the data in
population_density <- 
read_csv(here::here("_posts/2022-05-09-project-part-1/population-density.csv"))
  1. Use glimpse to see the names and types of the columns
glimpse(population_density)
Rows: 69,379
Columns: 4
$ Entity             <chr> "Afghanistan", "Afghanistan", "Afghanista~
$ Code               <chr> "AFG", "AFG", "AFG", "AFG", "AFG", "AFG",~
$ Year               <dbl> -10000, -9000, -8000, -7000, -6000, -5000~
$ population_density <dbl> 0.023, 0.031, 0.043, 0.060, 0.083, 0.115,~
view(population_density)
  1. Use output from glimpse (and view) to prepare the data for analysis
regions <- c( "USA" )
population_density <- population_density %>%
  rename(Region = 1, PD = 4) %>% 
  filter(Year == 2000) %>% 
  select(Region, Year, PD) 
population_density
# A tibble: 218 x 3
   Region               Year    PD
   <chr>               <dbl> <dbl>
 1 Afghanistan          2000  31.8
 2 Albania              2000 114. 
 3 Algeria              2000  13.0
 4 American Samoa       2000 289. 
 5 Andorra              2000 139. 
 6 Angola               2000  13.2
 7 Antigua and Barbuda  2000 173. 
 8 Argentina            2000  13.5
 9 Armenia              2000 108. 
10 Aruba                2000 505. 
# ... with 208 more rows

check that the total population density equals the total in the graph

population_density %>% 
  filter(Year == 2000)
# A tibble: 218 x 3
   Region               Year    PD
   <chr>               <dbl> <dbl>
 1 Afghanistan          2000  31.8
 2 Albania              2000 114. 
 3 Algeria              2000  13.0
 4 American Samoa       2000 289. 
 5 Andorra              2000 139. 
 6 Angola               2000  13.2
 7 Antigua and Barbuda  2000 173. 
 8 Argentina            2000  13.5
 9 Armenia              2000 108. 
10 Aruba                2000 505. 
# ... with 208 more rows

Add a picture populaton-density

Write the data to file in the project directory

write_csv(population_density, file = "population_density.csv")