Skip to content

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

@arunsrinivasan

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.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions