I have following data
Sample_ID<-c("a1_01_01","a2_03_03","a3_07_07","a4_09_09","a5_10_10","a6_21_21")
Sex<-c(M, M, F, F, M, NM)
DF1<-data.frame(Sample_ID,Sex)
I want to subset above df in the basis of following list.
Excluded <-c(a1_01, a3_07, a5_10)
I am using this code to execute
Newdf<-subset(DF1,Sample_ID %in% Excluded)
but its not working as you can see the Excluded and Sample_ID are not exactly same but their initials are similar. I have an idea that i need to pipe my R command with grep but couldnot figure out how to. Can someone please help me or if there is any other better simple way.