Mapping - vector and dataframe

Hi, I would like to map 'a' to 'd' according to columns in 'data'. I would be grateful for your help.

library(tibble)
a <- c(1,2,3,4,1,2)
b <- c(1,2,3,4)
c <- c("a","b","c","d")

data <- tibble(b,c)

Are you looking for something like this? It will return a named vector.

> deframe(x = data)[a]
  1   2   3   4   1   2 
"a" "b" "c" "d" "a" "b"
1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.