Skip to content

Commit

Permalink
rbindlist check message for automatic names too (#3484)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattdowle authored Mar 29, 2019
1 parent 8603485 commit 712e022
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

#### NOTES

1. As stated in news item 5 of v1.12.2, `rbindlist`'s `use.names="check"` now emits its message for automatic column names (`"V[0-9]+"`) too.


### Changes in v1.12.2 (submitted to CRAN on 28 Mar 2019)

Expand Down
2 changes: 1 addition & 1 deletion inst/tests/tests.Rraw
Original file line number Diff line number Diff line change
Expand Up @@ -13851,7 +13851,7 @@ test(2010.06, rbindlist(list(DT1,DT2)), ans, warning="item 2 appears in position
options(datatable.rbindlist.check="error")
test(2010.07, rbindlist(list(DT1,DT2)), error="item 2 appears in position 1.*See news item 5 in v1.12.2 for options to control this")
test(2010.08, rbindlist(list(DT1,data.table(foo=7:8, a=3:4))), error="Column 1 ['foo'] of item 2 is missing in item 1")
test(2010.09, rbindlist(list(DT1,data.table(V1=7:8, b=3:4))), ans) # ignore automatic column names though, for now for package tatoo
test(2010.09, rbindlist(list(DT1,data.table(V1=7:8, b=3:4))), error="Column 1 ['V1']") # automatic column names included in message (turned to error here) from 1.12.4; see news items
options(datatable.rbindlist.check="message")
test(2010.10, rbindlist(list(DT1,DT2)), ans, message="item 2 appears in position 1.*See news item 5 in v1.12.2 for options to control this")
options(datatable.rbindlist.check="none")
Expand Down
5 changes: 1 addition & 4 deletions src/rbindlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,17 +210,14 @@ SEXP rbindlist(SEXP l, SEXP usenamesArg, SEXP fillArg, SEXP idcolArg)
snprintf(buff, 1000, "Column %d ['%s'] of item %d is missing in item %d. Use fill=TRUE to fill with NA (NULL for list columns), or use.names=FALSE to ignore column names.%s",
w2+1, str, i+1, missi+1, extra );
if (usenames==TRUE) error(buff);
if (str[0]=='\0' || (str[0]=='V' && isdigit(str[1]))) { buff[0]='\0'; continue; } // temporarily ignore automatic column names using crude method to pass package tatoo
i = LENGTH(l); // break from outer i loop
break; // break from inner j loop
}
if (w!=j && usenames==NA_LOGICAL) {
SEXP s = getAttrib(VECTOR_ELT(l, i), R_NamesSymbol);
if (!isString(s) || i==0) error("Internal error: usenames==NA but an out-of-order name has been found in an item with no names or the first item. [%d]", i);
const char *str = CHAR(STRING_ELT(s,w));
if (str[0]=='\0' || (str[0]=='V' && isdigit(str[1]))) continue; // see comment above w.r.t. automatic column names
snprintf(buff, 1000, "Column %d ['%s'] of item %d appears in position %d in item %d. Set use.names=TRUE to match by column name, or use.names=FALSE to ignore column names.%s",
w+1, str, i+1, j+1, i, extra);
w+1, CHAR(STRING_ELT(s,w)), i+1, j+1, i, extra);
i = LENGTH(l);
break;
}
Expand Down

0 comments on commit 712e022

Please sign in to comment.