Skip to content

Commit

Permalink
fix order bug
Browse files Browse the repository at this point in the history
  • Loading branch information
zander-prinsloo committed Feb 26, 2024
1 parent c897e83 commit 3c188a9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 20 deletions.
23 changes: 5 additions & 18 deletions R/joyn-merge.R
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,6 @@ joyn <- function(x,
y <- as.data.table(y)
}


## Modify BY when is expression ---------
fixby <- check_by_vars(by, x, y)
by <- fixby$by
Expand Down Expand Up @@ -388,19 +387,6 @@ joyn <- function(x,
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Update x ---------
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

# if (isTRUE(update_values) || isTRUE(update_NAs)) {
# var_use <- sub(
# pattern = "\\.y$",
# replacement = "",
# x = newyvars[
# grepl(
# pattern = "\\.y$",
# x = newyvars
# )
# ]
# )
# }
var_use <- NULL
if (isTRUE(update_values) || isTRUE(update_NAs)) {
var_use <- common_vars
Expand Down Expand Up @@ -462,6 +448,11 @@ joyn <- function(x,
.yreport = NULL)


if (sort) {
setorderv(x, by, na.last = na.last)
setattr(x, 'sorted', by)
}

## Rename by variables -----

if (!is.null(fixby$xby)) {
Expand Down Expand Up @@ -519,10 +510,6 @@ joyn <- function(x,
x |> fselect(get(reportvar)) <- NULL
}

if (sort) {
setorderv(x, by, na.last = na.last)
setattr(x, 'sorted', by)
}

if (verbose == TRUE) {
end_joyn <- Sys.time()
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-joyn.R
Original file line number Diff line number Diff line change
Expand Up @@ -568,8 +568,8 @@ test_that("different names in key vars are working fine", {
".joyn" = c("x & y", "x & y", "x", "y", "x", "x & y", "y", "y")
)

setorderv(dd, "id1", na.last = TRUE)
setattr(dd, 'sorted', "id1")
setorderv(dd, c("id1", "id2"), na.last = TRUE)
setattr(dd, 'sorted', c("id1", "id2"))

expect_equal(df, dd)

Expand Down

0 comments on commit 3c188a9

Please sign in to comment.