Hi, I want to write a function, in which I can select any variables from different data frames (tibbles) and which will return the coefficients in a vector form. For example, this is my data frame:
And these are my suggested correlation tests (only a part of it):
cor(df1$a, df2$x1)
cor(df1$a, df2$x2)
cor(df1$a, df2$x3)
cor(df1$a, df2$y1)
cor(df1$a, df2$y2)
cor(df1$a, df2$y3)
cor(df1$b, df2$x1)
cor(df1$b, df2$x2)
cor(df1$b, df2$x3)
cor(df1$b, df2$y1)
cor(df1$b, df2$y2)
cor(df1$b, df2$y3)
How can I write a function so that I can specify the first group of variables in a vector (say x),
and specify the second group of variables in another vector (say y), and then get the results of cor(x,y) which will give all the suggested correlation coefficients in a vector?
Any alternative solutions would also be appreciated.