Hi I have tried many attempts but cant get the loop right, as I am not a strong programmer. What I am basically trying to do is compare 2 spreadsheets. The problem is that one of them only contain a portion of the overall data (TESTSAMP), where the other has a full datasetFULLSAMP. From the complete set I would like to remove the rows of data which are not in the TESTSAMP. Column 1 contains the sample numbers which can be used to identify samples. Does anyone have any suggestions?
I have tried various things like double loops and so on, but I am sure there is an easier way or function to do this. i tried this method, but Im not sure how to only keep looping until a match is found. I dont understand how repeat loops work in R. for (i in 1:length(FULLSAMP[,1])) { if (FULLSAMP[i,1] != TESTSAMP[i,1]) { FULLSAMP <- FULLSAMP[-i,] } Thanks in advance ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.