Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # This line should be changed!
- setwd("C:\\Users\\student\\Desktop\\")
- library(tidyr)
- # getting data
- cell_phones <- read.csv(file = "cell_phones_per_100_people.csv")
- # removing years over 2017
- #income <- income[,-c(220:242)]
- tmp.cell_phones <- gather(cell_phones, "year", "cell_phones_per_100_people", "X1960":"X2017")
- tmp.cell_phones$year <- substring(tmp.cell_phones$year, 2)
- tmp.cell_phones$country <- as.factor(tmp.cell_phones$country)
- tmp.cell_phones$year <- as.Date(tmp.cell_phones$year, "%Y")
- tmp.cell_phones$cell_phones_per_100_people <- as.numeric(tmp.cell_phones$cell_phones_per_100_people)
- falls <- read.csv(file = "falls_deaths_per_100000_people.csv")
- tmp.falls <- gather(falls, "year", "falls", "X1990":"X2016")
- tmp.falls$year <- substring(tmp.falls$year, 2)
- tmp.falls$country <- as.factor(tmp.falls$country)
- tmp.falls$year <- as.Date(tmp.falls$year, "%Y")
- tmp.falls$falls <- as.numeric(tmp.falls$falls)
- tmp <- merge(tmp.cell_phones, tmp.falls, by = c("year", "country"), all.x = TRUE)
- #data.all <- merge(tmp, tmp.broadband, by = c("year", "country"), all.x = TRUE)
- library(ggplot2)
- 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