library(ggplot2) #Required
library(dplyr) #Data wrangling
library(tidyr) #Data wrangling
library(rgeos) #Mapping
library(maptools) #Mapping
library(ggmap) #Mapping
library(broom) #Mapping
The following exercises will be based on the lga_profiles_data_2011_pt1.csv dataset, introduced in Module 6.
lga_profiles_data_2011_pt1 <- read.csv("lga_profiles_data_2011_pt1.csv")
Create a choropleth map in Carto using the lga_profiles_data_2011_pt1 dataset covered in the Module 6 notes, but this time, look at a different variable that you find interesting. This will require you to sign-up for a Carto account if you haven’t already done so. Publish the map, add a title, and paste the link to the published plot in an RMarkdown report. Submit this link along with a solution to Exercise 2 below.
https://alistairgj.carto.com/builder/41a261c0-1601-456b-93f7-8ec569820676/embed
Now recreate the choropleth map in Exercise 1 using ggplot2. Submit a knitted RMarkdown report to Canvas showing the link from Exercise 1 and the code and output from Exercise 2.
vic.lga.shp <- readShapeSpatial("vmlite_lga_cm.shp")
lga_profiles_data_2011_pt1 <- read.csv("lga_profiles_data_2011_pt1.csv")
lga.shp.f <- tidy(vic.lga.shp, region = "lga_name")
lga.shp.f$lga_name <-lga.shp.f$id
merge.lga.profiles<-merge(lga.shp.f, lga_profiles_data_2011_pt1,
by="lga_name", all.x=TRUE)
choro.data.frame<-merge.lga.profiles[order(merge.lga.profiles$order), ]
p1 <- ggplot(data = choro.data.frame,
aes(x = long, y = lat, group = group,
fill = households_with_internet_connected)) +
geom_polygon(color = "black", size = 0.25) +
coord_map() +
scale_fill_distiller(name = "Fraction of Households",
guide = "legend",
palette = "YlGnBu", direction = 1) +
theme_nothing(legend = TRUE) +
labs(title="Fraction of Households with Internet Connected")
p1
colnames(lga_profiles_data_2011_pt1)
## [1] "lga"
## [2] "lga_name"
## [3] "metro_rural"
## [4] "dh_region"
## [5] "area_of_lga_sq_km"
## [6] "asgc_code"
## [7] "most_populpus_community"
## [8] "distance_to_melbourne"
## [9] "travel_time_to_melbourne"
## [10] "remoteness_area"
## [11] "aria_measures_low_avg_high"
## [12] "business"
## [13] "industrial"
## [14] "residential"
## [15] "rural"
## [16] "other"
## [17] "per_annum_population_change_2000_2010"
## [18] "per_annum_projected_population_change_2010_2022"
## [19] "erp_2010_females_0_14"
## [20] "erp_2010_females_15_24"
## [21] "erp_2010_females_25_44"
## [22] "erp_2010_females_45_64"
## [23] "erp_2010_females_65_84"
## [24] "erp_2010_females_85"
## [25] "erp_2010_females_total"
## [26] "erp_2010_males_0_14"
## [27] "erp_2010_males_15_24"
## [28] "erp_2010_males_25_44"
## [29] "erp_2010_males_45_64"
## [30] "erp_2010_males_65_84"
## [31] "erp_2010_males_85"
## [32] "erp_2010_males_total"
## [33] "erp_2010_total_0_14"
## [34] "erp_2010_total_15_24"
## [35] "erp_2010_total_25_44"
## [36] "erp_2010_total_45_64"
## [37] "erp_2010_total_65_84"
## [38] "erp_2010_total_85"
## [39] "erp_2010_total"
## [40] "erp_2010_0_14"
## [41] "erp_2010_15_24"
## [42] "erp_2010_25_44"
## [43] "erp_2010_45_64"
## [44] "erp_2010_65_84"
## [45] "erp_2010_85"
## [46] "total_fertility_rate"
## [47] "rank_total_fertility_rate"
## [48] "atsi_population"
## [49] "rank_atsi_population"
## [50] "born_overseas"
## [51] "rank_born_overseas"
## [52] "speak_lote_at_home"
## [53] "rank_lote"
## [54] "low_english_proficiency"
## [55] "rank_low_english_proficiency"
## [56] "anglo_saxon_celtic_background"
## [57] "rank_anglo_saxon_celtic"
## [58] "new_settler_arrivals_per_100_000_population"
## [59] "rank_new_settler_arrivals"
## [60] "humanitarian_arrivals"
## [61] "rank_humanitarian_arrivals"
## [62] "believe_multiculturalism_makes_life_better"
## [63] "rank_believe_multiculturalism_makes_life_better"
## [64] "irsed"
## [65] "rank_irsed"
## [66] "households_with_internet_connected"
## [67] "rank_households_with_internet_connected"
## [68] "gaming_machine_losses_per_head_of_population"
## [69] "rank_gaming_machine_losses"
## [70] "family_incidents_per_1_000_population"
## [71] "rank_family_incidents_per_1_000_population"
## [72] "drug_usage_possession_offences_per_1_000_population"
## [73] "rank_drug_usage_possession_offences_per_1_000_population"
## [74] "total_offences_per_1_000_population"
## [75] "rank_total_offences_per_1_000_population"
## [76] "who_feel_safe_on_street_after_dark"
## [77] "rank_feel_safe_on_street_after_dark"
## [78] "of_population_which_volunteers"
## [79] "rank_population_which_volunteers"
## [80] "of_population_with_membership_of_organised_groups"
## [81] "rank_membership_of_organised_groups"
## [82] "of_parents_who_participate_in_schools"
## [83] "rank_parents_who_participate_in_schools"
## [84] "of_population_who_believe_the_area_has_good_facilities_and_se"
## [85] "rank_believe_the_area_has_good_facilities_and_services"
## [86] "unemployment_rate"
## [87] "rank_unemployment_rate"
## [88] "of_persons_with_individual_income_400_per_week"
## [89] "rank_individual_income_400"
## [90] "female_low_income"
## [91] "male_low_income"
## [92] "families_headed_by_one_parent"
## [93] "rank_one_parent_families"
## [94] "female_one_parent_families"
## [95] "male_one_parent_families"
## [96] "of_households_with_income_650_per_week"
## [97] "rank_households_with_income_650_per_week"
## [98] "low_income_families_with_children"
## [99] "rank_low_income_families_with_children"
## [100] "population_with_food_insecurity"
## [101] "rank_population_with_food_insecurity"
## [102] "of_households_with_housing_costs_40_of_income"
## [103] "rank_households_with_housing_costs_40_of_income"
## [104] "of_rental_housing_that_is_affordable"
## [105] "rank_rental_housing_that_is_affordable"
## [106] "median_house_price"
## [107] "rank_median_house_price"
## [108] "median_rent_for_3_bedroom_house"
## [109] "rank_median_rent_for_3_bedroom_house"
## [110] "new_dwellings_per_1_000_population"
## [111] "rank_new_dwellings_per_1_000_population"
## [112] "social_housing_as_a_percentage_of_total_dwellings"
## [113] "rank_social_housing_as_a_percentage_of_total_dwellings"
## [114] "dwellings_with_no_motor_vehicle"
## [115] "rank_dwellings_with_no_motor_vehicle"
## [116] "passenger_vehicles_per_1_000_population"
## [117] "rank_passenger_vehicles_per_1_000_population"
## [118] "motor_vehicles_more_than_ten_years_old"
## [119] "rank_motor_vehicles_more_than_ten_years_old"
## [120] "household_recycling_diversion_rate"
## [121] "rank_household_recycling_diversion_rate"
## [122] "household_garbage_yield_kg"
## [123] "rank_household_garbage_yield"
## [124] "fte_students"
## [125] "year_9_students_who_attain_tiol_minimum_standards_in_read"
## [126] "rank_year_9_students_who_attain_tiol_minimum_standards_in_r"
## [127] "year_9_students_who_attain_tiol_minimum_standards_in_writ"
## [128] "rank_year_9_students_who_attain_tiol_minimum_standards_in_w"
## [129] "year_9_students_who_attain_tiol_minimum_standards_in_nume"
## [130] "rank_year_9_students_who_attain_tiol_minimum_standards_in_n"
## [131] "of_population_who_did_not_complete_year_12"
## [132] "rank_population_who_did_not_complete_year_12"
## [133] "of_population_with_higher_education_qualification"
## [134] "rank_population_with_higher_education_qualification"
## [135] "students_attending_a_government_school"
## [136] "rank_students_attending_a_government_school"
## [137] "low_birth_weight_babies"
## [138] "rank_low_birth_weight_babies"
## [139] "persons_reporting_asthma"
## [140] "rank_persons_reporting_asthma"
## [141] "persons_reporting_type_2_diabetes"
## [142] "rank_persons_reporting_type_2_diabetes"
## [143] "asthma_admission_rate_ratio"
## [144] "rank_asthma_admission_rate_ratio"
## [145] "diabetes_complications_admission_rate_ratio"
## [146] "rank_diabetes_complications_admission_rate_ratio"
## [147] "persons_overweight_or_obese"
## [148] "rank_persons_overweight_or_obese"
## [149] "females_overweight_or_obese"
## [150] "rank_females_overweight_or_obese"
## [151] "males_overweight_or_obese"
## [152] "rank_males_overweight_or_obese"
## [153] "cancer_incidence_per_100_000_population"
## [154] "cancer_incidence___females_per_100_000"
## [155] "cancer_incidence___males_per_100_000"
## [156] "acsc_acute_per_1_000_population"
## [157] "rank_acsc_acute"
## [158] "acsc_chronic_per_1_000_population"
## [159] "rank_acsc_chronic"
## [160] "acsc_vaccine_preventablem_per_1_000_population"
## [161] "rank_acsc_vaccine_preventable"
## [162] "notifications_per_1_000_people_of_pertussis"
## [163] "rank_pertussis_notifications"
## [164] "notifications_per_1_000_people_of_influenza"
## [165] "rank_influenza_notifications"
## [166] "notifications_per_1_000_people_of_chlamydia"
## [167] "rank_chlamydia_notifications"