I have the following example data. I would like to lookup each of the values of the input_vector
and match those corresponding to letters from xxx
. So the output should be a character vector.
The catch is that I would like this to be vectorized and the length and order of the returned vector should always match to the input_vector
. I am sure this seems very simple but I would like to avoid using ifelse
as i have many more than 26 numbers/characters - in fact I am after the fastest piece of code, irrespective of dependencies. Obviously a plus if I can use data.table
.
nmbr<- 1:26
xxx <- data.table(data.frame(letters, nmbr), stringsAsFactors=FALSE)
input_vector<- setDT(as.data.table(round(runif(100, 1, 26))))