[R] compute differences

alessandro carletti alxmilton at yahoo.it
Mon Sep 21 14:39:47 CEST 2009


Hi,
I have a problem.
I have a data frame looking like:

ID val

A  .3
B  1.2
C  3.4
D  2.2
E  2.0

I need to CREATE the following TABLE:

CASE   DIFF

A-A    0
A-B    -0.9
A-C    -3.1
A-D    -1.9
A-E    -1.7
B-A    ...
B-B    ...
B-C
B-D
B-E
C-A
C-B
C-C
C-D
C-E
D-A
D-B
D-C
D-D
D-E
E-A
E-B
E-C
E-D
E-E

WHERE CASE IS THE COUPLE OF ELEMENTS CONSIDEREDM AND DIFF IS THE computed DIFFERENCE between their values.

Could you give me suggestions?

Alessandro Carletti







More information about the R-help mailing list