I would like to perform a two-sample t-test on my data within R. Given two high-dimensional data frames, I need to somehow loop through matching columns (String colnames() in header) over all rows and perform the test for each column pair - one from df1 and df2, respectively. The problem is that the columns from the data frames are not in right order, i.e. col1 form df1 doesn't match col1 from df2, and df2 has additional columns that don't exist in df1. I've never used R for such tasks and I wonder if there is a fast and handy solution to find matching column pairs in the data frames for the t-test.
I thought about for-loops but I think this would be very inefficient for large data frames.
Thank you in advance for any help.
*EDITED-------Two small example dataframes, df1 and df2--------------------------------
****df1****
"Row\Column" "A2" "A1" "A4" "A3"
"id_1" 10 20 0 40
"id_2" 5 15 25 35
"id_3" 8 0 12 16
"id_4" 17 25 0 40
****df2****
"Row\Column" "A3" "A8" "A5" "A6" "A1" "A7" "A4" "A2"
"id_1" 0 2 0 4 0 1 2 3
"id_2" 1 5 8 3 4 5 6 7
"id_3" 2 10 6 9 8 9 10 11
"id_4" 7 2 10 2 55 0 0 0
"id_5" 0 1 0 0 9 1 3 4
"id_6" 8 0 1 2 7 2 3 0
Matching columns are nothing but the columns names in df1 matching with the columnsnames in df2. For example Two matching columns in df1 and df2 are e. g. "A1" and "A1", "A2" and "A2" ... you get the idea...
df1
anddf2
would be helpful. You can usedput(head(df1)); dput(head(df2))
and copy+paste the output into your question. – Ricardo Saporta