Reorder one data.frame using two columns from another data.frame in R - Stack Overflow: "b[match(a$id,b$id),]
Unfortunately, I'm not sure how to accomplish the same thing when I need to order by two columns.
a:
id lob
1 1+ X
2 3 X
3 2 X
4 1 X
5 1 Y
6 1+ Y
7 1+ X
8 3 X
9 3 X
b:
id lob val
1 1+ X 1
2 1+ Y 9
3 1+ X 1
4 3 X 5
5 3 X 5
6 3 X 5
7 2 X 4
8 1 X 3
9 1 Y 2
I want to get this:
id lob val
1 1+ X 1
2 3 X 5
3 2 X 4
4 1 X 3
5 1 Y 2
6 1+ Y 9
7 1+ X 1
8 3 X 5
9 3 X 5
- Sent using Google Toolbar"
Unfortunately, I'm not sure how to accomplish the same thing when I need to order by two columns.
a:
id lob
1 1+ X
2 3 X
3 2 X
4 1 X
5 1 Y
6 1+ Y
7 1+ X
8 3 X
9 3 X
b:
id lob val
1 1+ X 1
2 1+ Y 9
3 1+ X 1
4 3 X 5
5 3 X 5
6 3 X 5
7 2 X 4
8 1 X 3
9 1 Y 2
I want to get this:
id lob val
1 1+ X 1
2 3 X 5
3 2 X 4
4 1 X 3
5 1 Y 2
6 1+ Y 9
7 1+ X 1
8 3 X 5
9 3 X 5
- Sent using Google Toolbar"
No comments:
Post a Comment