Skip to content

need 'rowid()' like 'rleid()' #1353

Closed
Closed

Description

@arunsrinivasan

Taken from here:

require(data.table)
dt <- data.table(subj = c(1,1,2,2,2), code = c("a", "b", "a", "d", "e"))

To use dcast, we need an awkward intermediate step:

dt[, grp := paste("var", seq_len(.N), sep=""), by=subj]

and then do:

dcast(dt, subj ~ grp, value.var="code")

Instead, it should be possible to do:

dcast(dt, subj ~ rowid(subj, prefix="var"), value.var="code")

Also update this SO post linked in #1205.

Activity

  1. added this to the v1.9.8 milestone on Sep 22, 2015
  2. changed the title [-]need 'grpid()' like 'rleid()'[/-] [+]need 'rowid()' like 'rleid()'[/+] on Sep 23, 2015
  3. MichaelChirico commented on Sep 24, 2015

    @MichaelChirico
    Member

    I guess this halfway sort of takes care of #1206 as well, if I'm not mistaken.

    And there's probably 30 SO answers that could use this! Let me see if I can dig some up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions