I have a dataset in which I have 450.000 columns and 660 rows. The first 330 rows are group "A" and the last 330 group "B". I would like to calculate the correlation per column between group A and group B.
so far I managed:
setkey(df, group)
cor(df["A"]$value, df["B"]$value)
Which returns me the correlation between the two groups for the first column.
However, I want to do this for all the 450.000 columns where I get in a new data frame with the column name and the correlation between the two groups.
Furthermore, I have to take into account that the first row of group A
(row 1) is related to the first row of group B
(row 331), the second of group A with the second of group B (row 2 and row 332) and so on.
Does anyone here have an idea how to achieve this in R?
Thank you all.