Adding an id for similar rows
Mostra commenti meno recenti
Hello,
I have a data set with row and column numbers in reference to a grid, and then a value for that cell.
Example of data set (Attached .csv titled "input")
row col value;
124 95 7983;
124 96 16142;
124 97 94846;
124 98 4557;
124 95 8935;
124 96 496746;
124 97 352734;
124 98 25374;
124 95 790574;
124 96 346;
124 97 3745;
124 98 19774;
What I'd like to do is add a column and for all the first unique row/column combinations, and populate the new column with 1. And then for the next repetition of those row/column combinations, use a 2 and so on. So this example data set would look like the following
ID row col value;
1 124 95 7983;
1 124 96 16142;
1 124 97 94846;
1 124 98 4557;
2 124 95 8935;
2 124 96 496746;
2 124 97 352734;
2 124 98 25374;
3 124 95 790574;
3 124 96 346;
3 124 97 3745;
3 124 98 19774;
I figured I could use the unique function to accomplish this, but I've been unsuccessful thus far. Does anyone have an easy way in mind to do this? Thanks so much. Oh, and the actual data files I'll be trying to apply this two are around 7 million lines, with around 600 different repetitions of the same row/column combinations, but different values going with the combinations each time. Thanks so much for your time!
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Creating, Deleting, and Querying Graphics Objects in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!