Import your data
data <- readr::read_csv("../00_data/myData.csv")
set.seed(1254)
data_small <- data %>%
select(brand, year, dislike_count) %>%
filter(!is.na(dislike_count)) %>%
sample_n(10)
data_small
## # A tibble: 10 × 3
## brand year dislike_count
## <chr> <dbl> <dbl>
## 1 Doritos 2009 215
## 2 Pepsi 2001 0
## 3 Bud Light 2003 3
## 4 Budweiser 2002 3
## 5 E-Trade 2001 7
## 6 Kia 2014 2
## 7 NFL 2020 7445
## 8 Doritos 2019 14
## 9 Bud Light 2007 134
## 10 Toyota 2020 11
Separating and Uniting
Unite two columns
data_united <- data %>%
unite(col = "newName", like_count:dislike_count, sep = "/", remove = TRUE)
Separate a column
data_united %>%
separate(col = newName, into = c("like_count", "dislike_count"), sep = "/")
## # A tibble: 247 × 25
## year brand superbowl_ads_dot_co…¹ youtube_url funny show_product_quickly
## <dbl> <chr> <chr> <chr> <lgl> <lgl>
## 1 2018 Toyota https://superbowl-ads… https://ww… FALSE FALSE
## 2 2020 Bud Light https://superbowl-ads… https://ww… TRUE TRUE
## 3 2006 Bud Light https://superbowl-ads… https://ww… TRUE FALSE
## 4 2018 Hynudai https://superbowl-ads… https://ww… FALSE TRUE
## 5 2003 Bud Light https://superbowl-ads… https://ww… TRUE TRUE
## 6 2020 Toyota https://superbowl-ads… https://ww… TRUE TRUE
## 7 2020 Coca-Cola https://superbowl-ads… https://ww… TRUE FALSE
## 8 2020 Kia https://superbowl-ads… https://ww… FALSE FALSE
## 9 2020 Hynudai https://superbowl-ads… https://ww… TRUE TRUE
## 10 2020 Budweiser https://superbowl-ads… https://ww… FALSE TRUE
## # ℹ 237 more rows
## # ℹ abbreviated name: ¹superbowl_ads_dot_com_url
## # ℹ 19 more variables: patriotic <lgl>, celebrity <lgl>, danger <lgl>,
## # animals <lgl>, use_sex <lgl>, id <chr>, kind <chr>, etag <chr>,
## # view_count <dbl>, like_count <chr>, dislike_count <chr>,
## # favorite_count <dbl>, comment_count <dbl>, published_at <dttm>,
## # title <chr>, description <chr>, thumbnail <chr>, channel_title <chr>, …
Missing Values