Skip to content
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

Update vals bug #70

Merged
merged 3 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: joyn
Type: Package
Title: Tool for Diagnosis of Tables Joins and Complementary Join Features
Version: 0.2.2.9000
Version: 0.2.2.9001
Authors@R: c(person(given = "R.Andres",
family = "Castaneda",
email = "[email protected]",
Expand Down
41 changes: 22 additions & 19 deletions R/joyn-merge.R
Original file line number Diff line number Diff line change
Expand Up @@ -385,25 +385,6 @@ joyn <- function(x,
)


#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Update jn ---------
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var_use <- NULL
if (isTRUE(update_NAs) || isTRUE(update_values)) {
var_use <- common_vars
}

if (isTRUE(update_NAs || update_values) & length(var_use) > 0 ) {

jn <- update_na_values(dt = jn,
var = var_use,
reportvar = reportvar,
suffixes = suffixes,
rep_NAs = update_NAs,
rep_values = update_values
)

}

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Filter rows - `keep` ---------
Expand All @@ -430,6 +411,28 @@ joyn <- function(x,
}


#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Update jn ---------
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var_use <- NULL
if (isTRUE(update_NAs) || isTRUE(update_values)) {
var_use <- common_vars
}

if (isTRUE(update_NAs || update_values) & length(var_use) > 0 ) {
# filter_var <- jn |>
# fselect(get(reportvar))
#print(filter_var)
jn <- update_na_values(dt = jn,
var = var_use,
reportvar = reportvar,
suffixes = suffixes,
rep_NAs = update_NAs,
rep_values = update_values
)

}

### common vars ----------

if (isFALSE(keep_common_vars)) {
Expand Down
27 changes: 27 additions & 0 deletions tests/testthat/test-joyn.R
Original file line number Diff line number Diff line change
Expand Up @@ -855,3 +855,30 @@ test_that("joyn() - input data unchanged", {
})


test_that("update_values still filters rows for left joins", {

x <- data.frame(id = 1:5,
a = 1:5,
b = 2:6)
y <- data.frame(id = c(1, 11, 2, 12, 5),
a = 11:15,
b = 12:16)

# for data.table
j1 <- joyn(x = qDT(x),
y = qDT(y),
by = "id",
keep = "left",
update_values = TRUE)

j2 <- joyn(x = x,
y = y,
by = "id",
keep = "left",
update_values = TRUE)

expect_true(all(j1$id %in% x$id))
expect_true(all(j2$id %in% x$id))

})

Loading