Advertisement
Guest User

Dollars per day in Africa with R

a guest
Jul 16th, 2019
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. pil.pro.capite.3$X2017 <-as.numeric(pil.pro.capite.3$X2017)
  2.  
  3. df<-pil.pro.capite.3 %>%
  4. mutate(dollars_per_day =X2017/365) %>%
  5. filter(Country %in% c("Algeria","Angola","Benin","Botswana","Burkina Faso","Burundi","Cameroon","Cabo Verde","Central African Republic","Chad","Comoros","Democratic Republic of the Congo","Republic of Congo","Côte d'Ivoire","Djibouti","Egypt","Equatorial Guinea","Eritrea","Ethiopia","Gabon","Gambia","Ghana","Guinea","Guinea-Bissau","Kenya","Lesotho","Liberia","Libya","Madagascar","Malawi","Mali","Mauritania","Mauritius","Morocco","Mozambique","Namibia","Niger","Nigeria","Rwanda","Senegal","Seychelles","Sierra Leone","South Africa","Sudan","Swaziland","Tanzania","Togo","Tunisia","Uganda","Zambia","Zimbabwe") ) %>%
  6. arrange(desc(dollars_per_day)) %>%
  7. select(Country,dollars_per_day)
  8.  
  9. write.csv(df,file = "dollari al giorno.csv",row.names = FALSE)
  10.  
  11. df %>%
  12. mutate(Country = reorder(Country,dollars_per_day) )%>%
  13. ggplot(aes(Country,dollars_per_day)) +
  14. geom_bar(stat = "identity",fill="gray",colour="red") +
  15. coord_flip() +
  16. ylab("Dollars per day") +
  17. xlab("African state") +
  18. ggtitle("Dollars per day", subtitle = "for African state in 2017 ")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement