I am trying to search for data inside of a vector. So I have two tables (turned into vectors), and I am trying to search the info of the vector "b" inside of the vector "a". Below my code is provided, does anyone knows how to fix this? I only get a TRUE/FALSE when in reallity I want to create a new vector. The column 2 of the "a" vector contains the info I am trying to search from vector "b".
a = read.table("data.txt",stringsAsFactors=FALSE,sep="\t")
a = as.vector(a[[2]])
b <- read.table("info.txt", stringsAsFactors = FALSE, sep = "\t")
b = as.vector(b[[1]])
f <- a[unlist(lapply(b, function(x) any(x %in% b)))]