-1

I am trying to merge Named Num values into an existing data.frame containing vector of equal names (and length). However the order in the data.frame is not the same order in the Named num so it is not correctly matching the value. I have been trying:

attr_B12$deg.bin<-deg_binary[match(names(deg_binary), attr_B12$Name)]

Where attr_B12$deg.bin is the new column I want to create in the existing data.frame (attr_B12), deg_binary is the Named Num [1:95] object, and attr_B12$Name is the vector of names which should match with the names associated with the Named Num…

But when I look at the data.frame there are incorrect values associated to the attr_B12$Name).

RamenChef
  • 5,557
  • 11
  • 31
  • 43
SarahM
  • 1
  • 1

1 Answers1

0

I dont't know if I get you right, but I would first try to use sort() to get both datasets into the same order (if there is a variable with the same values, preferably unique values).