[R] sum some columns for each row

Dawn dawn1313 at gmail.com
Thu Jul 9 19:12:30 CEST 2015


Hi,

I have a big dataframe as follows

    109ABC    109XYZ    18ABC    18XYZ    22XYZ    23ABC    25ABC    25XYZ
   30ABC    31XYZ    32ABC    32XYZ    34DCM    34XYZ    36ABC    36SUR
38DCM    38XYZ    39DCM    39SUR    41DCM    41SUR    42DCM    42SUR
46SUR    52DCM    64ABC    64XYZ    65ABC    65XYZ    66ABC    66XYZ
67XYZ    68ABC    68SUR    70MES    70SUR    72ABC    72XYZ    76ABC
76XYZ    82ABC    85ABC    POV
Cluster_1                                                        17    1
3    10    14    5    2    2        1    1    1    2
                        2                            TT:61
Cluster_2                    1                                4    20
6    5    3    6    9    9    6        10        1    3    1
                            4                            TT:88
Cluster_3    3        3                            6        4        17
17    18    13    17    19    22    11    5    21    8    5    18    4
7                                        9                            TT:227
........

I want to get two columns, i.e,  one is to sum columns for all including
ABC for each row and the other is  to sum columns for all including XYZ for
each row.

Is there some help? Thank you!
Dawn

	[[alternative HTML version deleted]]



More information about the R-help mailing list