list manipulation - How to keep first observation and delete other observations of each group in unbalanced Panel data
I have a huge panel data. I want to create a new data keeping only first observation of each group. How can I achieve it? For illustrative purpose;
mydata = {{1, a, aa}, {1, b, bb}, {1, c, cc}, {2, d, dd}, {2, e,
ee}, {3, f, ff}, {3, g, gg}, {3, h, hh}, {4, i, ii}, {4, j,
jj}, {4, k, kk}, {4, l, ll}, {4, m, mm}, {5, n, nn}, {5, o,
oo}, {7, p, pp}};
My final result should be:
myanswer = {{1, a, aa}, {2, d, dd}, {3, f, ff}, {4, i, ii}, {5, n,
nn}, {7, p, pp}};
Any help is greatly appreciated.
Comments
Post a Comment