How do I match corresponding rows of class labels to data
8 ビュー (過去 30 日間)
I have 838 by 400 matrix as my data, I also have a 275 by 2 file which contains my class labels but they are not organised to match the exact sample rows of the data, I need help with a code to match both so that the sample rows in the data matches the rows in the class labels. Any row that has no corresponding class lebels can be deleted. I need to end up with 275 by 400 data.
Note: The file with the data and the file with the class labels both have similar sample ID column to help idenify the sample rows.
Kinldy let me know if you need more clarification
Debadipto 2022 年 7 月 11 日
As per my understanding, you have two tables, table Data_to_match (838 by 400) and table GrpLabel_to_match (275 by 2). You want to keep only those rows in Data_to_match whose SampleID is present in GrpLabel_to_match and remove the other rows. To achieve this you can use the following code:
Data_to_match = Data_to_match(contains(Data_to_match.SampleID, GrpLabel_to_match.SampleID), :);
Please note that the dimension of the updated table Data_to_match will not be exactly 275 by 400 if the table GrpLabel_to_match contains any duplicate entries.