[R] Merge: sort=F not preserving order?
lol zino
lolzino at gmail.com
Wed Jan 27 23:13:40 CET 2010
Hello,
I have the following data1 (index are chars):
index
1 008823
2 012689
3 004503
4 002991
5 012689
6 002845
7 012689
8 012395
9 012689
10 009302
11 002845
12 006669
13 008823
14 009302
15 025340
16 012689
and data2 in this format (index2 are chars):
index2 tic
1 001003 ANTQ
2 001004 AIR
3 001009 ABSI
4 001011 ACSE
etc
I am attempting to merge them using the following:
mergeddata <- merge(data1,data2, by.x="index", by.y="index2", sort=FALSE)
I want to preserve the order of data1 by setting sort=FALSE, however
the output I get is:
index tic
1 008823 PHM
2 008823 PHM
3 012689 KBH
4 012689 KBH
5 012689 KBH
6 012689 KBH
7 012689 KBH
8 004503 XOM
9 002991 CVX
10 002845 CTX
11 002845 CTX
12 012395 TOL
13 009302 RYL
14 009302 RYL
15 006669 LEN
16 025340 DHI
which has not preserved the order of data1, and also does not have a
clear relationship to the order of data2 that I can see. I also tried
converting both index fields from chars to ints and got the same
result. Any ideas of what is going on here?
More information about the R-help
mailing list