Access data.table columns with strings

后端 未结 3 1127
予麋鹿
予麋鹿 2020-12-15 10:46

Apologies for a question that probably makes it obvious that I usually work in Python/pandas, but I\'m stuck with this. How do I select a data.table column usin

3条回答
  •  眼角桃花
    2020-12-15 11:22

    You can do assignments without get but using brackets:

    dt[, ("col1"):=col2]
    

    instead of:

    dt[, get("col1"):=col2]
    

    See for more explanation: Select / assign to data.table variables which names are stored in a character vector

提交回复
热议问题