I have two elements:
id1 <- "dog"
id2 <- "cat"
I want to extract any combination of these elements (dogcat or catddog) from a vector
L <- c("gdoaaa","gdobbb","gfoaaa","ghobbb","catdog")
L
I tried:
L[grep(paste(id1,id2,sep="")),L]
L[grep(paste(id2,id1,sep="")),L]
but this gives an error.
I would be grateful for your help in correcting the above.