Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
arunsrinivasan opened this issue Sep 22, 2015 · 1 comment
Closed

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

arunsrinivasan opened this issue Sep 22, 2015 · 1 comment
Assignees
Milestone

Comments

@arunsrinivasan
Copy link
Member

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.

@arunsrinivasan arunsrinivasan self-assigned this Sep 22, 2015
@arunsrinivasan arunsrinivasan added this to the v1.9.8 milestone Sep 22, 2015
@arunsrinivasan arunsrinivasan changed the title need 'grpid()' like 'rleid()' need 'rowid()' like 'rleid()' Sep 23, 2015
@MichaelChirico
Copy link
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
Projects
None yet
Development

No branches or pull requests

2 participants