[R] merge: How to preserve the original order?
Wolfram Fischer - Z/I/M
wolfram at fischer-zim.ch
Fri Oct 25 10:02:39 CEST 2002
x.vals <- data.frame(
id = c( 'A1', 'C2', 'B3' )
, ref = c( 'Ref1', 'Ref2' ,'Ref1' )
, val = c( 1.11, 2.22, 3.33 )
x.labels <- data.frame(
ref = c( 'Ref1', 'Ref2' )
, label = c( 'Label01', 'Label02' )
merge( x.vals, x.labels, by='ref', all.x = T, sort=F )
ref id val label
1 Ref1 A1 1.11 Label01
2 Ref1 B3 3.33 Label01
3 Ref2 C2 2.22 Label02
Alltough 'sort=F' is set, the original order: id = A1, C2, B3 is
not preserved. - Is there a possibility to preserve the original
order (when there is no key field which can be ordered after merging).
(Perhaps 'merge' is not the right solution for this problem?)
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
More information about the R-help