【发布时间】:2021-03-20 01:35:38
【问题描述】:
我有以下data.table:
name = c("Bob","Mary","Jane","Kim")
weight = c(60,65,45,55)
height = c(170,165,140,135)
dft = data.table(name,weight,height)
我想将 weight 更改为等于 height + 13 。我知道有很多方法可以做到这一点,例如
dft[, weight := height + 13
或
dft[, "weight" := height + 13
但是,由于我有一个庞大的数据集,其列名类似于V1, V2,....,V1000,我希望使用列名来输入修改。然而,在上面的例子中,
dft[, "weight" := "height" + 13
不工作。
所以我想知道如何使用 "height" 来修改weight。谢谢
【问题讨论】:
标签: r data.table