おぉ、凡ミス
誤
f542 <- function(x, y) {target[unique(as.numeric(sapply(1:length(x), function(i){grep(x[i], y)})))]}
正
f542 <- function(x, y) {y[unique(as.numeric(sapply(1:length(x), function(i){grep(x[i], y)})))]}