Azzera filtri
Azzera filtri

Matlab data sorting question

3 visualizzazioni (ultimi 30 giorni)
Daniel
Daniel il 22 Feb 2024
Risposto: Divyanshu il 5 Mar 2024
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 Commento
Star Strider
Star Strider il 22 Feb 2024
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.

Accedi per commentare.

Risposte (1)

Divyanshu
Divyanshu il 5 Mar 2024
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':

Categorie

Scopri di più su Resizing and Reshaping Matrices in Help Center e File Exchange

Prodotti


Release

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by