Dear R experts,
I have two data frames as follows
The column names in data1 correspond to the column "var" in data2.
I would like to sort data1 according to the information in data2. The absolute values of "r" indicate the importance of "var" and the sign of "r" indicates the directionality of sorting.
Because "y" has larger absolute r value than "x" in data2, sort data1 first with data1$y and then with data2$x
Because the sign of "x" is negative in data2, sort data1$x in an ascending fashion and because "y" is positive in data2, sort data1$y in a descending fashion.
I can make this sorting automatic without rewriting the script every time the values in data2 change.Suggestion will be appreciated.