[R] dataframe

n.vialma at libero.it n.vialma at libero.it
Wed Apr 21 10:01:34 CEST 2010


Dear list
I have a question, I would like to get the following results but I dont know 
how to do it:
I have a dataframe like this:

NC8                PROD                         X 1                X2
1423                 P1                                342               10
1564                 G5                                 56                 20
123                    G5                                  3                   
4
1568                    H2                                
6                      10
7864                    H2                                
5                      72
5693                      P3                               
7                       43

What I would like to do is the sum of the X1 and X2 variables by PROD, namely 
getting another dataframe which looks like the following

NC8                PROD                         X 1                
X2                               
1423                 P1                                342               10
1564                 G5                                 59                24
123                    G5                                  59                 
24
1568                    H2                                11                   
82
7864                    H2                                
11                    82
5693                      P3                               
7                       43


In Sas I know a function called proc means that can do it.
How can I do this in R???



More information about the R-help mailing list