Using one data.frame to update another

后端 未结 7 419

Given 2 data frames that are identical in terms of column names/datatypes, where some columns uniquely identify the rows, is there an efficient function/method for one data.

7条回答
  •  囚心锁ツ
    2020-12-20 12:50

    Just set a unique ID as the row names. Then it is simple indexing:

    rownames(original) = original$Id
    rownames(replacement) = replacement$Id
    
    original[rownames(replacement), ] = replacement
    

提交回复
热议问题