Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. # This line should be changed!
  2. setwd("C:\\Users\\student\\Desktop\\")
  3.  
  4. library(tidyr)
  5.  
  6. # getting data
  7. cell_phones <- read.csv(file = "cell_phones_per_100_people.csv")
  8. # removing years over 2017
  9. #income <- income[,-c(220:242)]
  10.  
  11. tmp.cell_phones <- gather(cell_phones, "year", "cell_phones_per_100_people", "X1960":"X2017")
  12. tmp.cell_phones$year <- substring(tmp.cell_phones$year, 2)
  13. tmp.cell_phones$country <- as.factor(tmp.cell_phones$country)
  14. tmp.cell_phones$year <- as.Date(tmp.cell_phones$year, "%Y")
  15. tmp.cell_phones$cell_phones_per_100_people <- as.numeric(tmp.cell_phones$cell_phones_per_100_people)
  16.  
  17. falls <- read.csv(file = "falls_deaths_per_100000_people.csv")
  18. tmp.falls <- gather(falls, "year", "falls", "X1990":"X2016")
  19. tmp.falls$year <- substring(tmp.falls$year, 2)
  20. tmp.falls$country <- as.factor(tmp.falls$country)
  21. tmp.falls$year <- as.Date(tmp.falls$year, "%Y")
  22. tmp.falls$falls <- as.numeric(tmp.falls$falls)
  23.  
  24. tmp <- merge(tmp.cell_phones, tmp.falls, by = c("year", "country"), all.x = TRUE)
  25. #data.all <- merge(tmp, tmp.broadband, by = c("year", "country"), all.x = TRUE)
  26.  
  27. library(ggplot2)
  28.  
  29. ggplot(data = tmp, aes(x = cell_phones_per_100_people, y = falls, color = year)) + geom_point()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement