I have two tables. Both are read using the read.table() function.
Table 1
A B C
S1 1 1 0
S2 2 0 NA
S3 0 2 1
Table 2
Pa Pb Pc
G1 0.12 0.65 0.001
G2 0.34 0.82 0.03
G3 0.2 0.64 0.87
I need to iterate over both tables. Specifically, I need to iterate over table one column-wise and extract pairwise combinations for each of the entries in a particular column.
For example,
From the first column in table 1, I need to extract the values of all pairwise permutations of the elements in column 1, i.e., {1, 2}, {1, 0},{2, 0}, {2, 1}, {0, 1}, {0, 2}.
Using these values, and an element in Table 2 (this example, element [0, 1]), I will fit to a first order linear regression model.
Does anyone have any suggestions how best to iterate over table one to isolate all those pairwise permutations?
For getting the combinations by column in the first table, you can do this:
It will depend on how you want the final data to look. It might be more sensible as a list: