Guest User

Untitled

a guest
Oct 20th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. require(countrycode)
  2.  
  3. # To UpperCase Country
  4. my.data$Land <- toupper(my.data$Land)
  5.  
  6. #weitere Länder?
  7. my.data$Land[my.data$Land == "UK"] <- "GB" ##UK to GB
  8.  
  9. #region
  10. region <- countrycode(my.data$Land, "iso2c", "region")
  11.  
  12. #continent
  13. continent <- countrycode(my.data$Land, "iso2c", "continent")
  14.  
  15. #ergänzen Regionen und Kontinent
  16. my.data <- cbind(my.data,region,continent)
  17.  
  18. my.data <- na.omit(my.data)
  19.  
  20. #ergänzen Anzahl Quellen per Land
  21. tmp <- as.data.frame(table(unlist(my.data$Land)))
  22.  
  23. my.data.complete <- merge(my.data,tmp, by.x="Land",by.y="Var1")
  24.  
  25. #export Tabelle
  26. write.csv(my.data.complete,"BASEDok.csv")
Add Comment
Please, Sign In to add comment