Skip to content

Commit 747c76c

Browse files
committed
dat_for_default_fill is zero-row dt
1 parent 83b0cf5 commit 747c76c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

R/fcast.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ dcast.data.table = function(data, formula, fun.aggregate = NULL, sep = "_", ...,
159159
fun.call = quote(length)
160160
}
161161
}
162-
dat_for_default_fill = dat
162+
dat_for_default_fill = dat[0]
163163
run_agg_funs = !is.null(fun.call)
164164
if (run_agg_funs) {
165165
fun.call = aggregate_funs(fun.call, lvals, sep, ...)
@@ -213,7 +213,7 @@ dcast.data.table = function(data, formula, fun.aggregate = NULL, sep = "_", ...,
213213
fill.default = NULL
214214
some_fill = anyNA(idx)
215215
if (run_agg_funs && is.null(fill) && some_fill) {
216-
fill.default = dat_for_default_fill[0L][, maybe_err(eval(fun.call))]
216+
fill.default = dat_for_default_fill[, maybe_err(eval(fun.call))]
217217
}
218218
ans = .Call(Cfcast, lhs, val, maplen[[1L]], maplen[[2L]], idx, fill, fill.default, is.null(fun.call), some_fill)
219219
allcols = do.call("paste", c(rhs, sep=sep))

0 commit comments

Comments
 (0)