What is the correlation between GDP, and total food of waste per year?

#View Data

library(readr)
## Warning: ³Ì¼­°ü'readr'ÊÇÓÃR°æ±¾4.1.3 À´½¨ÔìµÄ
country_level <- read_csv("C:/Users/ywang/Desktop/country_level_data_0.csv")
## Rows: 217 Columns: 51
## -- Column specification --------------------------------------------------------
## Delimiter: ","
## chr (10): iso3c, region_id, country_name, income_id, other_information_infor...
## dbl (41): gdp, composition_food_organic_waste_percent, composition_glass_per...
## 
## i Use `spec()` to retrieve the full column specification for this data.
## i Specify the column types or set `show_col_types = FALSE` to quiet this message.
View(country_level)
names(country_level)
##  [1] "iso3c"                                                                                
##  [2] "region_id"                                                                            
##  [3] "country_name"                                                                         
##  [4] "income_id"                                                                            
##  [5] "gdp"                                                                                  
##  [6] "composition_food_organic_waste_percent"                                               
##  [7] "composition_glass_percent"                                                            
##  [8] "composition_metal_percent"                                                            
##  [9] "composition_other_percent"                                                            
## [10] "composition_paper_cardboard_percent"                                                  
## [11] "composition_plastic_percent"                                                          
## [12] "composition_rubber_leather_percent"                                                   
## [13] "composition_wood_percent"                                                             
## [14] "composition_yard_garden_green_waste_percent"                                          
## [15] "other_information_information_system_for_solid_waste_management"                      
## [16] "other_information_national_agency_to_enforce_solid_waste_laws_and_regulations"        
## [17] "other_information_national_law_governing_solid_waste_management_in_the_country"       
## [18] "other_information_ppp_rules_and_regulations"                                          
## [19] "other_information_summary_of_key_solid_waste_information_made_available_to_the_public"
## [20] "population_population_number_of_people"                                               
## [21] "special_waste_agricultural_waste_tons_year"                                           
## [22] "special_waste_construction_and_demolition_waste_tons_year"                            
## [23] "special_waste_e_waste_tons_year"                                                      
## [24] "special_waste_hazardous_waste_tons_year"                                              
## [25] "special_waste_industrial_waste_tons_year"                                             
## [26] "special_waste_medical_waste_tons_year"                                                
## [27] "total_msw_total_msw_generated_tons_year"                                              
## [28] "waste_collection_coverage_rural_percent_of_geographic_area"                           
## [29] "waste_collection_coverage_rural_percent_of_households"                                
## [30] "waste_collection_coverage_rural_percent_of_population"                                
## [31] "waste_collection_coverage_rural_percent_of_waste"                                     
## [32] "waste_collection_coverage_total_percent_of_geographic_area"                           
## [33] "waste_collection_coverage_total_percent_of_households"                                
## [34] "waste_collection_coverage_total_percent_of_population"                                
## [35] "waste_collection_coverage_total_percent_of_waste"                                     
## [36] "waste_collection_coverage_urban_percent_of_geographic_area"                           
## [37] "waste_collection_coverage_urban_percent_of_households"                                
## [38] "waste_collection_coverage_urban_percent_of_population"                                
## [39] "waste_collection_coverage_urban_percent_of_waste"                                     
## [40] "waste_treatment_anaerobic_digestion_percent"                                          
## [41] "waste_treatment_compost_percent"                                                      
## [42] "waste_treatment_controlled_landfill_percent"                                          
## [43] "waste_treatment_incineration_percent"                                                 
## [44] "waste_treatment_landfill_unspecified_percent"                                         
## [45] "waste_treatment_open_dump_percent"                                                    
## [46] "waste_treatment_other_percent"                                                        
## [47] "waste_treatment_recycling_percent"                                                    
## [48] "waste_treatment_sanitary_landfill_landfill_gas_system_percent"                        
## [49] "waste_treatment_unaccounted_for_percent"                                              
## [50] "waste_treatment_waterways_marine_percent"                                             
## [51] "where_where_is_this_data_measured"
dim(country_level)
## [1] 217  51
library(dplyr)
## Warning: ³Ì¼­°ü'dplyr'ÊÇÓÃR°æ±¾4.1.3 À´½¨ÔìµÄ
## 
## 载入程辑包:'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
country_level_waste <-summarize(country_level,country_level$country_name,country_level$composition_food_organic_waste_percent,country_level$gdp)
summarize(country_level,country_level$country_name,country_level$composition_food_organic_waste_percent,country_level$gdp)                                                                         
## # A tibble: 217 x 3
##    `country_level$country_name` country_level$composition_food_organic~1 count~2
##    <chr>                                                           <dbl>   <dbl>
##  1 Aruba                                                            NA    35563.
##  2 Afghanistan                                                      NA     2057.
##  3 Angola                                                           51.8   8037.
##  4 Albania                                                          51.4  13724.
##  5 Andorra                                                          31.2  43712.
##  6 United Arab Emirates                                             39    67119.
##  7 Argentina                                                        38.7  23550.
##  8 Armenia                                                          57    11020.
##  9 American Samoa                                                   19.7  11113.
## 10 Antigua and Barbuda                                              46    17966.
## # ... with 207 more rows, and abbreviated variable names
## #   1: `country_level$composition_food_organic_waste_percent`,
## #   2: `country_level$gdp`
colnames(country_level_waste) <- c("Country","Food of Waste Per Year","GDP")

#Count: Total Food of Waste vs. GDP

country_level_waste %>% count(country_level_waste$`Food of Waste Per Year`,country_level_waste$GDP)
## # A tibble: 217 x 3
##    `country_level_waste$\`Food of Waste Per Year\`` country_level_waste$~1     n
##                                               <dbl>                  <dbl> <int>
##  1                                             3.1                 117336.     1
##  2                                             4.8                   4784.     1
##  3                                             5.35                 58806.     1
##  4                                             6.5                  24216.     1
##  5                                             8                     3629.     1
##  6                                             8.1                  14126.     1
##  7                                            10                    55274.     1
##  8                                            10.5                  97341.     1
##  9                                            10.9                  66207.     1
## 10                                            12                     3068.     1
## # ... with 207 more rows, and abbreviated variable name
## #   1: `country_level_waste$GDP`

#Correlation between Total food of Waste and GDP

country_level_waste %>% group_by(country_level_waste$country_level$`Food of Waste Per Year`)
## Warning: Unknown or uninitialised column: `country_level`.
## # A tibble: 217 x 3
##    Country              `Food of Waste Per Year`    GDP
##    <chr>                                   <dbl>  <dbl>
##  1 Aruba                                    NA   35563.
##  2 Afghanistan                              NA    2057.
##  3 Angola                                   51.8  8037.
##  4 Albania                                  51.4 13724.
##  5 Andorra                                  31.2 43712.
##  6 United Arab Emirates                     39   67119.
##  7 Argentina                                38.7 23550.
##  8 Armenia                                  57   11020.
##  9 American Samoa                           19.7 11113.
## 10 Antigua and Barbuda                      46   17966.
## # ... with 207 more rows
plot(country_level_waste$`Food of Waste Per Year`,country_level_waste$"GDP",main="Food of Waste vs GDP",xlab='Waste in Food',ylab="GDP")

cor(country_level_waste$`Food of Waste Per Year`,country_level_waste$GDP,method=c("pearson"),use = "complete.obs")
## [1] -0.4366114

##Summary: There is a correlation between Food of Waste vs GDP (-0.43)