-
Notifications
You must be signed in to change notification settings - Fork 1k
export uniq function (uniqlist) #4372
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
Open
jangorecki
wants to merge
15
commits into
master
Choose a base branch
from
uniqlist
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
cc27941
uniqueN logical unfold for codecov
jangorecki 81e7391
uniqlengths reduce loop overhead, unfold for codecov
jangorecki 96ec1a2
refactor code for easy folding
jangorecki ac8e6b8
exporting uniq function (uniqlist), #900
jangorecki 4a4fc1d
extend man for order arg example, fix old tests, breaking change?
jangorecki f5bcbf3
internal uniqlist reverted to match previous tests
jangorecki 02415a5
uniq unit tests, uniqlist as well, document segfault when internal=T
jangorecki 11e1020
uniqueNlogical codecov, uniqlengths test num to int
jangorecki fef3aec
news and more manual
jangorecki bcdc65a
if needs all, unlike stopifnot, fix
jangorecki 58beb63
segfault proof public api
jangorecki aed71cf
manual entry align
jangorecki c93ed24
another manual entry fix
jangorecki b589fad
test coverage
jangorecki a09a54f
proper codecov fix
jangorecki File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| \name{uniq} | ||
| \alias{uniq} | ||
| \alias{uniqlist} | ||
| \alias{funiq} | ||
| \title{ Consecutively unique rows } | ||
| \description{ | ||
| Finds the consecutively unique rows. | ||
| } | ||
| \usage{ | ||
| uniq(x, order=integer()) | ||
| } | ||
| \arguments{ | ||
| \item{x}{ data.table type object. } | ||
| \item{order}{ integer vector order of \code{x}, must not contain duplicates. } | ||
| } | ||
| \details{ | ||
| Works like UNIX \emph{uniq} as referred to by \code{\link[base]{unique}}; i.e., it drops immediately repeated rows but doesn't drop duplicates of any previous row. Unless \code{order} is provided, then it also drops any previous row. | ||
| } | ||
| \note{ | ||
| It is an undefined behavior when \code{order} argument contains duplicates. It was designed to take what the \code{\link[base]{order}} function returns. We do not check for duplicates, although we still check for values to be in range \code{1:nrow(x)} and non-NA, to avoid \emph{segfault} exception. | ||
| } | ||
| \value{ | ||
| Integer vector corresponding to rows which are consecutively unique. | ||
| } | ||
| \seealso{ \code{\link{data.table}}, \code{\link{rleid}} } | ||
| \examples{ | ||
| uniq(data.table()) | ||
| uniq(data.table(x=integer())) | ||
| uniq(data.table(x=integer(), y=integer())) | ||
| uniq(data.table(x=1L)) | ||
| uniq(data.table(x=1L, y=1L)) | ||
| uniq(data.table(x=1:2)) | ||
| uniq(data.table(x=1:2, y=1:2)) | ||
| uniq(data.table(x=1:2)[c(1L,1:2)]) | ||
| uniq(data.table(x=1:2, y=1:2)[c(1L,1:2)]) | ||
|
|
||
| # 'order' argument | ||
| x = data.table(id = 1:8, v = rep(1:2, each=4)) | ||
| uniq(x[,"v"]) | ||
| x = x[c(1:2,7:8,3:4,5:6)] | ||
| uniq(x[,"v"]) | ||
|
|
||
| o = order(x$id) | ||
| uniq(x[,"v"], order=o) | ||
| # or if we are not sure if 'o' has no duplicates | ||
| if (!anyDuplicated(o)) { | ||
| uniq(x[,"v"], order=o) | ||
| } | ||
| } | ||
| \keyword{ data } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.