-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from finddx/sample-classification
better find duplicates function
- Loading branch information
Showing
11 changed files
with
139 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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 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 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,27 @@ | ||
# WARNING - Generated by {fusen} from dev/sample_selections.Rmd: do not edit by hand | ||
|
||
#' Mark All Duplicates in a Vector | ||
#' | ||
#' This function identifies all duplicate elements in a vector, marking both the first | ||
#' occurrence and subsequent duplicates. | ||
#' | ||
#' @param vec A numeric or character vector where duplicates are to be identified. | ||
#' | ||
#' @return A logical vector of the same length as `vec`, where TRUE indicates that | ||
#' the corresponding element in `vec` is a duplicate. | ||
#' | ||
#' @export | ||
#' @examples | ||
#' | ||
#' vec <- c("apple", "banana", "apple", "cherry", "banana") | ||
#' mark_all_duplicates(vec) | ||
mark_all_duplicates <- function(vec) { | ||
# Check duplicates from the start and from the end | ||
dup_from_start <- duplicated(vec) | ||
dup_from_end <- duplicated(vec, fromLast = TRUE) | ||
|
||
# Combine the two to mark all duplicates (including first occurrences) | ||
all_duplicates <- dup_from_start | dup_from_end | ||
return(all_duplicates) | ||
} | ||
|
This file contains 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 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 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 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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,5 @@ | ||
# WARNING - Generated by {fusen} from dev/sample_selections.Rmd: do not edit by hand | ||
|
||
test_that("mark_all_duplicates works", { | ||
expect_true(inherits(mark_all_duplicates, "function")) | ||
}) |
This file contains 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