Using one data.frame to update another

后端 未结 7 442

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:48

    require(plyr)
    indexes_to_replace <- rownames(match_df(original,replacement,on='Id'))
    indexes_from_replace<-rownames(match_df(replacement,original,on='Id'))
    original[indexes_to_replace,] <- replacement[indexes_from_replace,]
    

    param on of function match_df can take vectors as well.

提交回复
热议问题