How to rank variable and create a new variable to display the order? for example, following data frame, want to sort the data by var1 and generate a new variable for the order, let ties have the same order number. Thank you!
input<-("var1 var2
1 2
3 4
1 3
2 5
2 6
4 5
6 7")
mydata<- read.table(textConnection(input),header=T)