I expose my problem. I have these 3 dataframe:
single
Mat Price
A 1029.90
B 568.52
C 497.12
D 573.50
E 217.92
double
Mat1 Mat2 Price
A C 1529.61
A D 1623.49
A E 1325.86
B C 1050.64
B D 1146.65
B E 849.02
C D 999.42
C E 700.03
D E 776.41
triple
Mat1 Mat2 Mat3 Price
B C D 1564.98
B C E 1267.30
C D E 1350.45
B D E 1202.33
Using these 3 dataframes I have to build another dataframe (or list) that gives me all the possible combinations that contain once and only letters from A to E.
For example, some possible combinations can be: A | B | C | D | E | taken from the dataframe single
, or AC taken from the dataframe double
and B | D | E taken from the dataframe single
, or BCD taken from the dataframe triple
and e AE taken from the dataframe double
and so on for all combinations.
Moreover for every combination found I would like to dedicate a column of the dataframe to the prices calculated as:
(sum of the price from which the material was taken) + 500 * (number of groupings used in the combination).
Taking up the previous examples: the combination A | B | C | D | E | taken all in the dataframe single
will have a price equal to
(1029.90 + 568.52 + 497.12 + 573.50 + 217.92) + 500 * (5)
The combination AC | B | D | E will have a price equal to (1529.61 + 568.52 + 573.50 + 217.92) + 500 * (4)
The AE | BCD combination will have a price equal to (1325.86 + 1564.98) + 500 * (2)
Is it possible to create a function in R that automates this process? Thanks so much