Creating column that groups data from another columns

Creating column that groups data from another columns

1

Hello
I have data that look like this

     group     a    b   c   d
     AO1      10  10 14 15
     AO1       8   8 17 15
     AO1      12  15 17 20 
     A02       8   5  2  8
     A02      18   9 12  5
     A02       8   5  2  9
     A03      14  15 10 10  
     A03       9   5  3 16   
     A11      12   5  8  8 
     A11       2   3 12  4 
     A12      12  17 10  2
     A12       9   7  5  8
     A13      18  10 15  9
     A13       2   1  9  4
     A21       9  12  1  7
     A21      10   4 15 13
     A22      17   8  5  8
     A22       9  10  6 17
     A23       7  10  1  3
     A23      17   4 15 12

And i wat to create another columns that groups informations from the columns Group :

so the output i want is this :

   group  supgrp   a   b  c  d
     AO1     A0    10  10 14 15
     AO1     A0     8   8 17 15
     AO1     A0    12  15 17 20 
     A02     A0     8   5  2  8
     A02     A0    18   9 12  5
     A02     A0     8   5  2  9
     A03     A0    14  15 10 10  
     A03     A0     9   5  3 16   
     A11     A1    12   5  8  8 
     A11     A1     2   3 12  4 
     A12     A1    12  17 10  2
     A12     A1     9   7  5  8
     A13     A1    18  10 15  9
     A13     A1     2   1  9  4
     A21     A2     9  12  1  7
     A21     A2    10   4 15 13
     A22     A2    17   8  5  8
     A22     A2     9  10  6 17
     A23     A2     7  10  1  3
     A23     A2    17   4 15 12

Thank you very much


R


statistics


function


data

• 36 views


updated 48 minutes ago by

17k

written 2 hours ago by

▴

20

Read more here: Source link

Tagged