-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrefine_clean code
More file actions
15 lines (15 loc) · 1.99 KB
/
refine_clean code
File metadata and controls
15 lines (15 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
library(dplyr)
library(tidyr)
refine <- tbl_df(refine_original)
refine <- refine %>% mutate(company = ifelse(company == "Phillips", "philips", ifelse(company == "phillips", "philips", ifelse(company == "phllips", "philips", ifelse(company == "phillps", "philips", ifelse(company == "phillipS", "philips", ifelse(company == "philips", "philips", ifelse(company == "fillips", "philips", ifelse(company == "phillips", "philips", ifelse(company == "phlips", "philips", ifelse(company == "akzo", "akzo", ifelse(company == "Akzo", "akzo", ifelse(company == "AKZO", "akzo", ifelse(company == "akz0", "akzo", ifelse(company == "ak zo", "akzo", ifelse(company == "Van Houten", "van houten", ifelse(company == "van Houten", "van houten", ifelse(company == "van houten", "van houten", ifelse(company == "unilver", "unilever", ifelse(company == "unilever", "unilever", ifelse(company == "Unilever", "unilever", "")))))))))))))))))))))
refine <- refine %>% separate(`Product code / number`, into=c("product_code", "product_number"), sep = "-")
refine <- refine %>% mutate(product_category = ifelse(product_code == "p", "Smartphone", ifelse(product_code == "x", "Laptop", ifelse(product_code == "v", "TV", ifelse(product_code == "q", "Tablet", "")))))
refine <- refine %>% unite(full_address, c(address, city, country), sep = ",")
refine <- refine %>% mutate(company_philips = ifelse(company == "philips", "1", "0"))
refine <- refine %>% mutate(company_akzo = ifelse(company == "akzo", "1", "0"))
refine <- refine %>% mutate(company_van_houten = ifelse(company == "van houten", "1", "0"))
refine <- refine %>% mutate(company_unilever = ifelse(company == "unilever", "1", "0"))
refine <- refine %>% mutate(product_smartphone = ifelse(product_category == "Smartphone", "1", "0"))
refine <- refine %>% mutate(product_tv = ifelse(product_category == "TV", "1", "0"))
refine <- refine %>% mutate(product_laptop = ifelse(product_category == "Laptop", "1", "0"))
refine <- refine %>% mutate(product_tablet = ifelse(product_category == "Tablet", "1", "0"))