Let I have such a data frame(df):
col1 col2 col3
x1 x3 x4
x2 y1 y2
y3 y4 y5
And let an another input data frame(dfi) is:
col1 col2
y 2
x 1
Desired output data frames are:
data frame1(df1):
col1 col2 col3
x1 y1 y2
x2 y4 y5
data frame2(df2):
col1 col2 col3
y3 y1 x4
y4
data frame3(df3):
col1 col2 col3
y3 x3 y2
y5
Namely,
I want to create data frames where
- each column will consist of only x values or only y values
- the input data frame (dfi) says each output dafa frame will consists of only 2 "y" columns and 1 "x" column
- and all possible different combinations of such data frames must be produced.
How can I create such data frames using R? My original data frame is much larger and the second input data frame dfi can change. I know this is difficult problem. I will be very glad for any help. Thanks a lot.