Import your data
data <- read_csv("data/myData.csv")
## Rows: 1024 Columns: 16
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (4): name, generation, type, abilities
## dbl (9): id, height, weight, hp, attack, defense, special-attack, special-de...
## lgl (3): is_baby, is_legendary, is_mythical
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Separating and Uniting
Separate a column
datasep <- data %>%
separate(col = type, into = c("type1", "type2"))
## Warning: Expected 2 pieces. Missing pieces filled with `NA` in 499 rows [4, 5, 7, 8, 9,
## 10, 11, 19, 20, 23, 24, 25, 26, 27, 28, 29, 30, 32, 33, 35, ...].
Unite two columns
datasep%>%
unite(col = "type", c(type1,type2), sep ="/", )
## # A tibble: 1,024 × 16
## name id height weight is_baby is_legendary is_mythical generation type
## <chr> <dbl> <dbl> <dbl> <lgl> <lgl> <lgl> <chr> <chr>
## 1 bulbas… 1 7 69 FALSE FALSE FALSE generatio… gras…
## 2 ivysaur 2 10 130 FALSE FALSE FALSE generatio… gras…
## 3 venusa… 3 20 1000 FALSE FALSE FALSE generatio… gras…
## 4 charma… 4 6 85 FALSE FALSE FALSE generatio… fire…
## 5 charme… 5 11 190 FALSE FALSE FALSE generatio… fire…
## 6 chariz… 6 17 905 FALSE FALSE FALSE generatio… fire…
## 7 squirt… 7 5 90 FALSE FALSE FALSE generatio… wate…
## 8 wartor… 8 10 225 FALSE FALSE FALSE generatio… wate…
## 9 blasto… 9 16 855 FALSE FALSE FALSE generatio… wate…
## 10 caterp… 10 3 29 FALSE FALSE FALSE generatio… bug/…
## # ℹ 1,014 more rows
## # ℹ 7 more variables: abilities <chr>, hp <dbl>, attack <dbl>, defense <dbl>,
## # `special-attack` <dbl>, `special-defense` <dbl>, speed <dbl>