[R] dataframe

Ivan Calandra ivan.calandra at uni-hamburg.de
Wed Apr 21 10:24:26 CEST 2010


Hi,

You should send your data using dput() so that we can copy/paste into 
the console.

That said, aggregate() or doBy::summaryBy() might do what you're looking 
for.

HTH,
Ivan


Le 21-Apr-10 10:01, n.vialma at libero.it a écrit :
> 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???
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>



More information about the R-help mailing list