小编chr*_*iss的帖子

尝试更新一列并创建另一列时,R data.table段错误

是否可以在data.table中创建新列并同时更新现有列?以下不起作用.谢谢.

library(data.table)
dt <- data.table(x=runif(4), y=runif(4), z=c("x","x","y","y"))
dt[, c("x", "y") := list(x[1], y[1]), by=z]     # works
dt[, c("x", "newx") := list(x[1], y[1]), by=z]
Run Code Online (Sandbox Code Playgroud)

抓到Segfault:

address 0x20000010, cause 'memory not mapped'
Run Code Online (Sandbox Code Playgroud)

追溯:

 1: [.data.table(dt, , :=(c("x", "newx"), list(x[1], y[1])), by = z)
 2: dt[, :=(c("x", "newx"), list(x[1], y[1])), by = z]
Run Code Online (Sandbox Code Playgroud)

r data.table

7
推荐指数
1
解决办法
298
查看次数

标签 统计

data.table ×1

r ×1