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

more verbose merge errors #6689

Closed
wants to merge 1 commit into from
Closed
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
18 changes: 15 additions & 3 deletions R/merge.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,15 @@
if (length(by.x)==0L || !is.character(by.x) || !is.character(by.y))
stopf("A non-empty vector of column names is required for `by.x` and `by.y`.")
if (!all(by.x %chin% nm_x))
stopf("Elements listed in `by.x` must be valid column names in x.")
stopf(paste(
"Elements listed in `by.x` must be valid column names in x.",
"\n Missing from `x`:", paste(setdiff(by.x, nm_x), collapse = ", ")

Check warning on line 41 in R/merge.R

View workflow job for this annotation

GitHub Actions / lint-r

file=R/merge.R,line=41,col=34,[paste_linter] toString(.) is more expressive than paste(., collapse = ", "). Note also glue::glue_collapse() and and::and() for constructing human-readable / translation-friendly lists
))
if (!all(by.y %chin% nm_y))
stopf("Elements listed in `by.y` must be valid column names in y.")
stopf(paste(
"Elements listed in `by.y` must be valid column names in y.",
"\n Missing from `y`:", paste(setdiff(by.y, nm_y), collapse = ", ")

Check warning on line 46 in R/merge.R

View workflow job for this annotation

GitHub Actions / lint-r

file=R/merge.R,line=46,col=34,[paste_linter] toString(.) is more expressive than paste(., collapse = ", "). Note also glue::glue_collapse() and and::and() for constructing human-readable / translation-friendly lists
))
by = by.x
names(by) = by.y
} else {
Expand All @@ -51,7 +57,13 @@
if (length(by) == 0L || !is.character(by))
stopf("A non-empty vector of column names for `by` is required.")
if (!all(by %chin% intersect(nm_x, nm_y)))
stopf("Elements listed in `by` must be valid column names in x and y")
stopf(
paste(
"Elements listed in `by` must be valid column names in x and y.",
if(length(setdiff(by, nm_x)) > 0) "\n Missing from `x`:", paste(setdiff(by, nm_x), collapse = ", "),

Check warning on line 63 in R/merge.R

View workflow job for this annotation

GitHub Actions / lint-r

file=R/merge.R,line=63,col=70,[paste_linter] toString(.) is more expressive than paste(., collapse = ", "). Note also glue::glue_collapse() and and::and() for constructing human-readable / translation-friendly lists
if(length(setdiff(by, nm_y)) > 0) "\n Missing from `y`:", paste(setdiff(by, nm_y), collapse = ", ")

Check warning on line 64 in R/merge.R

View workflow job for this annotation

GitHub Actions / lint-r

file=R/merge.R,line=64,col=70,[paste_linter] toString(.) is more expressive than paste(., collapse = ", "). Note also glue::glue_collapse() and and::and() for constructing human-readable / translation-friendly lists
)
)
by = unname(by)
by.x = by.y = by
}
Expand Down
Loading