Skip to content

Commit

Permalink
removed magrittr dependencies
Browse files Browse the repository at this point in the history
resolves #4
  • Loading branch information
dunkenwg committed Jul 16, 2024
1 parent e772880 commit 91040e3
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 13 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ Config/testthat/edition: 3
Encoding: UTF-8
Language: en-US
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
RoxygenNote: 7.3.2
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export(coalesce_data)
export(collapse_comments)
export(drop_na_all)
export(drop_uninformative_columns)
export(duplicates)
export(if_else2)
export(only)
export(replace_na_if)
Expand Down
12 changes: 6 additions & 6 deletions R/duplicates.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ duplicates <- function(x, cols = colnames(x)) {
check_values(cols, "")
check_names(x, cols)

x %<>% tibble::as_tibble()
x <- tibble::as_tibble(x)

cols %<>% unique()
cols <- unique(cols)

if (!length(cols)) {
return(x)
}

y <- x[cols]
y <- y[duplicated(y), , drop = FALSE] %>%
unique()
x %<>% merge(y, by = cols)
x %<>% dplyr::as_tibble()
y <- y[duplicated(y), , drop = FALSE]
y <- unique(y)
x <- merge(x, y, by = cols)
x <- dplyr::as_tibble(x)
x
}
19 changes: 19 additions & 0 deletions man/duplicates.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/if_else2.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/str_detect2.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions tests/testthat/test-duplicates.R
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
test_that("can read multiple hobo csv file", {
tib <- dplyr::tibble(x = c(1, 2, 1), y = c(1, 1, 1))
expect_identical(ps_duplicates(tib), tib[c(1, 3), ])
expect_identical(ps_duplicates(as.data.frame(tib)), tib[c(1, 3), ])
expect_identical(duplicates(tib), tib[c(1, 3), ])
expect_identical(duplicates(as.data.frame(tib)), tib[c(1, 3), ])

expect_equal(
ps_duplicates(data.frame(x = c(1, 2, 1), y = 1:3), "x"),
duplicates(data.frame(x = c(1, 2, 1), y = 1:3), "x"),
dplyr::tibble(x = c(1, 1), y = c(1, 3))
)
expect_equal(
ps_duplicates(data.frame(x = c(1, 2, 1), y = 1:3), c("x", "y")),
duplicates(data.frame(x = c(1, 2, 1), y = 1:3), c("x", "y")),
dplyr::tibble(x = double(0), y = double(0))
)
})

0 comments on commit 91040e3

Please sign in to comment.