Current data:
df <- data.frame(
name = c("Steve", "Darrel", "Barney", "Lola"),
age = c("12_pink", "14_green", "19_blue", "24_cyan"),
sex = c("M", "M", "M", "F")
)
I am trying to fill the 'colors' column with the color that is in the 'age' column so it looks like the following.
Desired data:
name | age | sex | color |
---|---|---|---|
Steve | 12 | M | pink |
Darrel | 14 | M | green |
Barney | 19 | M | blue |
Lola | 24 | F | cyan |
Anyways to do so? I was thinking of using mutate()
to create the color
column but wasn't sure how to fill it.