I have a dataframe with two columns, which are the initials of a name (col1) and an assigned value to it (col2)
dat <- data.frame(col1 = c("A","B","C"), col2 = c(4,5,6)) %>% as_tibble()
And i have a named vector, whose names are the initials and the values are the full names
nam <- c("A" = "Andrew", "B" = "Bob", "C" = "Charles")
Given that i would like to have a third name with these names using dplyr's mutate once i am working in a pipe. The dataset should be something like this by the end.
dat2 <- data.frame(col1 = c("A","B","C"), col2 = c(4,5,6), col3 = c("Andrew","Bob","Charles")) %>% as_tibble()
How can i achieve this?