[R] sum rows in a data.frame

arnaud Gaboury arnaud.gaboury at gmail.com
Thu Apr 15 09:50:12 CEST 2010


Dear group,

Here is a data.frame, "lme":

> lme
                          DESCRIPTION CLOSING.PRICE POSITION
4        PRIMARY NICKEL USD 04/06/10    25,755.7100        0
5        PRIMARY NICKEL USD 10/06/10    25,760.8600        0
6  PRM HGH GD ALUMINIUM USD 09/07/10     2,415.9000        0
8  SPCL HIGH GRADE ZINC USD 06/07/10     2,420.1000       -1
9  SPCL HIGH GRADE ZINC USD 07/07/10     2,420.4100       -1
10 SPCL HIGH GRADE ZINC USD 08/07/10     2,420.7300        1
11 SPCL HIGH GRADE ZINC USD 09/07/10     2,421.0500        1
12 SPCL HIGH GRADE ZINC USD 13/04/10     2,388.4300        0
13 SPCL HIGH GRADE ZINC USD 14/04/10     2,389.0000        0
14 SPCL HIGH GRADE ZINC USD 15/04/10     2,389.5700        0
15 SPCL HIGH GRADE ZINC USD 17/05/10     2,402.2900        0
16 SPCL HIGH GRADE ZINC USD 18/05/10     2,402.6400       -2

DESCRIPTION and CLOSING.PRICE are factors, POSITION is numeric.

I want to sum POSITION by products, i.e. PRIMARY NICKEL, PRM HGH GD
ALUMINIUM and SPCL HIGH GRADE ZINC. The problem is that, as you can see,
there is a different date as a part of each product description. Can anyone
tell me how to get rid of these dates so I can sum the position column? The
number of rows is not fixed and will change every day.

TY.



More information about the R-help mailing list