You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use ngettext() for some plural messages in R (#6476)
* ngettext() for R-side plural messages
* Fix test references
* Find and switch more ngettext candidates in R
* missing ','
* Another round of tests fixes
* Remove ':' from message too in test
if (any(tt!=xnrow)) stopf("The items in the 'by' or 'keyby' list are length(s) %s. Each must be length %d; the same length as there are rows in x (after subsetting if i is provided).", brackify(tt), xnrow)
901
+
if (any(tt!=xnrow)) {
902
+
plural_part<- sprintf(ngettext(length(tt), "The item in the 'by' or 'keyby' list is length %s.", "The items in the 'by' or 'keyby' list have lengths %s."), brackify(tt))
903
+
stopf("%s Each must be length %d; the same length as there are rows in x (after subsetting if i is provided).", plural_part, xnrow)
904
+
}
899
905
if (is.null(bynames)) bynames= rep.int("",length(byval))
900
906
if (length(idx<- which(!nzchar(bynames))) &&!bynull) {
901
907
# TODO: improve this and unify auto-naming of jsub and bysub
if (is.character(neworder)&& anyDuplicated(names(x)))
2735
-
stopf("x has some duplicated column name(s): %s. Please remove or rename the duplicate(s) and try again.", brackify(unique(names(x)[duplicated(names(x))])))
2740
+
if (is.character(neworder))
2741
+
check_duplicate_names(x)
2736
2742
if (!is.null(before) &&!is.null(after))
2737
2743
stopf("Provide either before= or after= but not both")
msg<- gettext("Aggregating function(s) should take a vector as input and return a single value (length=1), but they do not, so the result is undefined. Please fix by modifying your function so that a single value is always returned.")
195
+
msg<- gettext("Aggregating functions should take a vector as input and return a single value (length=1), but they do not, so the result is undefined. Please fix by modifying your function so that a single value is always returned.")
196
196
if (is.null(fill)) { # TODO change to always stopf #6329
stopf("Duplicate columns are not allowed in overlap joins. This may change in the future.")
45
45
if (length(by.x) != length(by.y))
46
46
stopf("length(by.x) != length(by.y). Columns specified in by.x should correspond to columns specified in by.y and should be of same lengths.")
47
-
if (any(dup.x<-duplicated(names(x)))) #1730 - handling join possible but would require workarounds on setcolorder further, it is really better just to rename dup column
48
-
stopf("%s has some duplicated column name(s): %s. Please remove or rename the duplicate(s) and try again.", "x", brackify(unique(names(x)[dup.x])))
49
-
if (any(dup.y<-duplicated(names(y))))
50
-
stopf("%s has some duplicated column name(s): %s. Please remove or rename the duplicate(s) and try again.", "y", brackify(unique(names(y)[dup.y])))
47
+
48
+
#1730 - handling join possible but would require workarounds on setcolorder further, it is really better just to rename dup column
Copy file name to clipboardExpand all lines: R/merge.R
+3-2Lines changed: 3 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -21,10 +21,11 @@ merge.data.table = function(x, y, by = NULL, by.x = NULL, by.y = NULL, all = FAL
21
21
else
22
22
warningf("Input data.table '%s' has no columns.", "y")
23
23
}
24
+
check_duplicate_names(x)
25
+
check_duplicate_names(y)
26
+
24
27
nm_x= names(x)
25
28
nm_y= names(y)
26
-
if (anyDuplicated(nm_x)) stopf("%s has some duplicated column name(s): %s. Please remove or rename the duplicate(s) and try again.", "x", brackify(nm_x[duplicated(nm_x)]))
27
-
if (anyDuplicated(nm_y)) stopf("%s has some duplicated column name(s): %s. Please remove or rename the duplicate(s) and try again.", "y", brackify(nm_y[duplicated(nm_y)]))
28
29
29
30
## set up 'by'/'by.x'/'by.y'
30
31
if ( (!is.null(by.x) ||!is.null(by.y)) && length(by.x)!=length(by.y) )
ngettext(nfail, "%d error out of %d. Search %s for test number %s. Duration: %s.", "%d errors out of %d. Search %s for test numbers %s. Duration: %s."),
0 commit comments