:= (pass by reference) operator in the data.table package modifies another data table object simultaneously

前端 未结 1 628
猫巷女王i
猫巷女王i 2020-12-01 15:52

While testing my code, I found out the following: If I assign a data.table DT1 to DT and change DT afterwards, DT1 change

相关标签:
1条回答
  • 2020-12-01 16:34

    This piece of documentation in data.table would help. ? data.table::copy

    No value is returned. The data.table is modified by reference. If you require a copy, take a copy first (using DT2=copy(DT)). copy() may also sometimes be useful before := is used to subassign to a column by reference.

    0 讨论(0)
提交回复
热议问题