I smell the response to the data. table answer, but here is the approach to finding the environment:
n <-50; set.seed(10) x <-sample(1:20,50,rep=T) inputs <- c(4,3,5) outputs <- c(2,4,6) library(qdap) lookup(x, inputs, outputs, missing = NULL)
This person asked for a test:

On a 10,000 length vector (10 repetitions):
Unit: microseconds expr min lq median uq max neval LOOKUP() 9875.384 9992.475 10236.9230 10571.405 11588.846 10 REPLACE() 76.973 85.837 94.7005 104.031 111.961 10 PLYR() 904.082 924.142 952.8315 973.124 1017.442 10 MATCH() 1796.034 1825.423 1864.3760 1881.870 1902.396 10
source share