I have the following two data frames
df1 <- as.data.frame(matrix(runif(50), nrow = 10, byrow = TRUE))
colnames(df1) <- c("x1", "x2", "x3", "x4", "x5")
df2 <- as.data.frame(matrix(runif(100), nrow = 20, byrow = TRUE))
colnames(df2) <- c("x1", "x2", "x3", "x4", "x5")
And I would like to test if the mean of columns x_j is the same for the 2 dfs, for j=1,...,5, recording the test statistic and p value.
t.test(df1$x1, df2$x1)$statistic
t.test(df1$x1, df2$x1)$p.value
apply() seems to only take one df as input? What's the best way to loop the above 2 lines over j?
Thanks in advance!