Skip to content

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

Closed

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.

Activity

  1. eantonya commented on Jul 22, 2015

    @eantonya
    Contributor

    I haven't thought this through very carefully, but I assume whatever argument applies to .GRP also applies to .BY.

  2. jangorecki commented on Aug 16, 2015

    @jangorecki
    Member

    Not sure but maybe it is only a matter of adjusting regex in two lines of [.data.table:
    jvnames = gsub("^[.]([NI])$","\\1",as.character(jsub)) in data.table.R#L896
    jvnames[jj-1L] = gsub("^[.]([NI])$","\\1",deparse(jsubl[[jj]])) in data.table.R#L907

  3. MichaelChirico commented on Sep 11, 2015

    @MichaelChirico
    MemberAuthor

    @jangorecki perhaps these lines as well

  4. arunsrinivasan commented on Sep 11, 2015

    @arunsrinivasan
    Member

    @MichaelChirico no, just the ones Jan's pointed. Would be great to wrap this up..

  5. MichaelChirico commented on Sep 11, 2015

    @MichaelChirico
    MemberAuthor

    @arunsrinivasan gonna take care of it now. Is there anything that needs to be changed in the tests / manual for this?

  6. added a commit that references this issue on Sep 11, 2015
    0797313
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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