Matlab data sorting question

3 次查看(过去 30 天)
Daniel
Daniel 2024-2-22
回答: Divyanshu 2024-3-5
I have been wokring with a dataset that I have examined using Matlab for some time. For whatever reason, the creators of the set decided that they were going to change IDs for many entries in the set. The two IDs of interest are specimen id and external sample id, and for most entries in the set at least one of these was changed. I was wondering if anyone had reccomendations on how to compare these two data sets and the old vs. new IDs to try and get a sense of which entries are linked to each other and which had values changed. I have attempted to do so but I tend to get lost in all the moving parts. Thanks!
  1 个评论
Star Strider
Star Strider 2024-2-22
If only the IDs have changed and the accompanying data have remained the same, one option might be the ismember function on everything defining the data except the IDs, since you would likely be looking for an exact match. You would need to experiment to get the desired result.

请先登录,再进行评论。

回答(1 个)

Divyanshu
Divyanshu 2024-3-5
Hi Daniel,
A possible way to match and find out which entries from old-dataset are linked to which entries in new-dataset after updation of 'Specimen Id' & 'External Sample Id' is by identifying and using a third variable or column in the dataset which is unique and unchanged across old & new datasets.
Assuming that a third column with unique and unchanged values between old & new datasets exist, refer the following points:
  • Create a dictionary data type and make the values of 'Col3' as keys of dictionary.
  • Now iterate over the new dataset and push the 'Specimen Id' as value to the key.
  • Iterate over the old dataset and for each value of 'Col3' fetch its value from dictionary which is corresponding new Id.
  • Now you have both old Id and Updated Id which you can use or link.
Note: 'Col3' is the assumed third column with unique values in a set and those values are not changed between old & new dataset.
You can refer the following documentation for more details on 'dictionary':

类别

Help CenterFile Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息

标签

产品


版本

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by