Skip to content

Bug: .GRP should create column named GRP, not .GRP (a la .I, .N) #1243

@MichaelChirico

Description

@MichaelChirico

That .GRP returns a variable named .GRP by default is causing some errors.

Consider:

data.table(id=rep(1:3,each=5),yr=rep(rep(1:3,3),rep(c(2,1,2),3)))[,.GRP,by=.(id,yr)][,!.GRP%in%range(.GRP),by=id]

(Basically, trying to eliminate the first and last yr of observation from each id)

This is an error: cannot change value of locked binding for '.GRP'. I can think of a number of workarounds, but it seems the simpler solution is to simply change the naming behavior.

I imagine this is the same reason why .I and .N return columns named I and N by default.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions