I have a data table called DT in R and I have a subtable called VIDEOSEL. I want to create a new table called NDT that contains the rows of DT only if they appear in VIDEOSEL.
For example: DT=
NAME UNID
54 4
37 7
122 8
VIDEOSEL=
NAME UNID
54 14
NDT=
NAME UNID
54 4
I have this code
NDT<-NULL
for (i in 1:dim(DT)[1]){
mat<-is.na(match(DT$NAME[i],VIDEOSEL$NAME))
if(mat)
{
NDT<-rbind(NDT,DT[i,])
}
}
The problem is that it is terribly slow because DT has 150000 elements. How can I improve the peformance?
Thanks a lot