replacing values in a column with another column R

后端 未结 4 1363
滥情空心
滥情空心 2020-11-30 10:47

I have two tables in different dimensions, now I want to replace value datA$swl1 with values in datB$swl2 according to userids.

datA

 id swl1
 1            


        
4条回答
  •  忘掉有多难
    2020-11-30 11:23

    IIUC, using data.table v1.9.5:

    require(data.table)
    setDT(datA)[datB, swl1 := swl2, on = "id"]
    

    datA is updated by reference.

提交回复
热议问题