I have two data.frames that looks like:
df1 Gene name sample1 sample2 sample3 sample4 sample5 A 0 1 0 0 1 B 1 0 0 1 0 C 0 0 1 1 1 D 1 0 0 1 0 df_final Gene name sample1 sample2 sample3 sample4 sample5 A 1 1 1 0 0 B 0 1 0 0 0 C 1 1 0 0 0 D 1 1 0 0 0
Only values of "0" and "1" are present. I would like a single data.frame in which when an entry in df1 or df2 is == 1 in both data.frames it will be maintained as "1" (the same with "0"). Otherwise, when it is == 1 in one data.frame (df1 for example) and 0 in the other data.frame (df2 for example) the entry will become 1. The two data.frames have the same number of rows and the same number of columns.
The desired output will be:
df1 Gene name sample1 sample2 sample3 sample4 sample5 A 1 1 1 0 1 B 1 1 0 1 0 C 1 1 1 1 1 D 1 1 0 1 0
Since I' m new in R I would like to use for loops on the first and second data.frame to learn to loop over multiple data.frames. At the moment I'm not able to do such work. Can anyone help me please?
Best,
E.