Displaying 2 results from an estimated 2 matches for "label01".
Did you mean:
label0
2002 Oct 25
1
merge: How to preserve the original order?
...- 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 )
I received:
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...
2012 Jan 15
0
patching ?merge to allow the user to keep the order of one of the two data.frame objects merged
...) && any(keep_order == c(1,2))) return(order.by.id...
and.remove.it(res))
res
}
#############################
########## Example
#############################
if(F) # example
{
x <- data.frame(
ref = c( 'Ref1', 'Ref2' )
, label = c( 'Label01', 'Label02' )
)
y <- data.frame(
id = c( 'A1', 'C2', 'B3', 'D4' )
, ref = c( 'Ref1', 'Ref2' , 'Ref3','Ref1' )
, val = c( 1.11, 2.22, 3.33, 4.44 )
)
x
y
merge( x, y, by...