Skip to content

[R-Forge #5376] When DT is empty, DT[, newcol:=max(b), by=a] does not add the column #49

@arunsrinivasan

Description

@arunsrinivasan

Submitted by: shubh bansal; Assigned to: Arun ; R-Forge link

In an empty data.table, defining a new column by reference by group does not add the column to the table.

In the example below, I would expect an empty column 'c' to be added to the data.table

dt1=data.table(a=character(0),b=numeric(0))
dt1
# Empty data.table (0 rows) of 2 cols: a,b
dt1[, c:=max(b), by='a']
dt1
# Empty data.table (0 rows) of 2 cols: a,b

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions