sorting - r two dataframe merge by absolute value of one column -


i have 2 dataframes same format looking this:

df1)

name value score      2    0.01  b     2    2.25  c     1    5.24 

df2)

name value score      2    -8.01  b     2    -3.25  c     1    -2.24 

i want merge these 2 list according absolute value of "score" column

output)

name value score      2    -8.01  c     1    5.24  b     2    -3.25  b     2    2.25  c     1    -2.24      2    0.01 

would there simple r code this? appreciate help. thanks

rbind , order rows:

newdat <- rbind(dat1,dat2) newdat[order(abs(newdat$score),decreasing=true),]  #  name value score #4        2 -8.01 #3    c     1  5.24 #5    b     2 -3.25 #2    b     2  2.25 #6    c     1 -2.24 #1        2  0.01 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -