Skip to content

Commit 5a4e09f

Browse files
committed
Implement all=TRUE argument for rleid (Fixes #1963)
1 parent f6bbd5b commit 5a4e09f

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

R/data.table.R

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3091,11 +3091,11 @@ rowidv = function(x, cols=seq_along(x), prefix=NULL) {
30913091
}
30923092

30933093
# FR #686
3094-
rleid = function(..., prefix=NULL) {
3095-
rleidv(list(...), prefix=prefix)
3094+
rleid = function(..., prefix=NULL,all=FALSE) {
3095+
rleidv(list(...), prefix=prefix, all=all)
30963096
}
30973097

3098-
rleidv = function(x, cols=seq_along(x), prefix=NULL) {
3098+
rleidv = function(x, cols=seq_along(x), prefix=NULL, all = FALSE) {
30993099
if (!is.null(prefix) && (!is.character(prefix) || length(prefix) != 1L))
31003100
stopf("'prefix' must be NULL or a character vector of length 1.")
31013101
if (is.atomic(x)) {
@@ -3109,6 +3109,9 @@ rleidv = function(x, cols=seq_along(x), prefix=NULL) {
31093109
cols = colnamesInt(x, cols, check_dups=FALSE)
31103110
ids = .Call(Crleid, x, cols)
31113111
if (!is.null(prefix)) ids = paste0(prefix, ids)
3112+
if (isTRUE(all)) {
3113+
return(c(x, list(ids)))
3114+
}
31123115
ids
31133116
}
31143117

0 commit comments

Comments
 (0)