Skip to content

Commit 6b6bf76

Browse files
Suggest fcoalesce() for some errors
1 parent 8f5ffa8 commit 6b6bf76

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/nafill.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,13 @@ SEXP nafillR(SEXP obj, SEXP type, SEXP fill, SEXP nan_is_na_arg, SEXP inplace, S
180180
isInt64[i] = INHERITS(VECTOR_ELT(x, i), char_integer64);
181181
const void **fillp = (const void **)R_alloc(nx, sizeof(*fillp)); // fill is (or will be) a list of length nx of matching types, scalar values for each column, this pointer points to each of those columns data pointers
182182
if (hasFill) {
183-
if (nx!=length(fill) && length(fill)!=1)
184-
error(_("fill must be a vector of length 1 or a list of length of x"));
183+
if (nx!=length(fill) && length(fill)!=1) {
184+
if (itype == 0) {
185+
error(_("fill must be a vector of length 1 or a list of length of x. Consider fcoalesce() to specify element-wise replacements."));
186+
} else {
187+
error(_("fill must be a vector of length 1 or a list of length of x."));
188+
}
189+
}
185190
if (!isNewList(fill)) {
186191
SEXP fill1 = fill;
187192
fill = PROTECT(allocVector(VECSXP, nx)); protecti++;

0 commit comments

Comments
 (0)