We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
as.data.table(table(NULL)) # Error in (function (..., sorted = TRUE, unique = FALSE) : # attempt to set an attribute on NULL
with full traceback():
traceback()
5: (function (..., sorted = TRUE, unique = FALSE) { l = list(...) if (isFALSE(getOption("datatable.CJ.names", TRUE))) { if (is.null(vnames <- names(l))) vnames = paste0("V", seq_len(length(l))) else if (any(tt <- vnames == "")) vnames[tt] = paste0("V", which(tt)) } else { vnames = name_dots(...)$vnames if (any(tt <- vnames == "")) vnames[tt] = paste0("V", which(tt)) } dups = FALSE for (i in seq_along(l)) { y = l[[i]] if (!length(y)) next if (sorted) { if (!is.atomic(y)) stop("'sorted' is TRUE but element ", i, " is non-atomic, which can't be sorted; try setting sorted = FALSE") o = forderv(y, retGrp = TRUE) thisdups = attr(o, "maxgrpn", exact = TRUE) > 1L if (thisdups) { dups = TRUE if (length(o)) l[[i]] = if (unique) y[o[attr(o, "starts", exact = TRUE)]] else y[o] else if (unique) l[[i]] = y[attr(o, "starts", exact = TRUE)] } else { if (length(o)) l[[i]] = y[o] } } else { if (unique) l[[i]] = unique(y) } } nrow = prod(vapply_1i(l, length)) if (nrow > .Machine$integer.max) stop(gettextf("Cross product of elements provided to CJ() would result in %.0f rows which exceeds .Machine$integer.max == %d", nrow, .Machine$integer.max, domain = "R-data.table")) l = .Call(Ccj, l) setDT(l) l = setalloccol(l) setnames(l, vnames) if (sorted) { if (!dups) setattr(l, "sorted", names(l)) else setkey(l) } l })(V1 = NULL, sorted = FALSE) 4: do.call(CJ, c(val, sorted = FALSE)) 3: data.table(do.call(CJ, c(val, sorted = FALSE)), N = as.vector(x), key = key) 2: as.data.table.table(table(NULL)) 1: as.data.table(table(NULL))
Probably we should return data.table(NULL) here.
data.table(NULL)
Use case: edge case of a code that was returning proper tables the rest of the time.
The text was updated successfully, but these errors were encountered:
dput(as.data.frame(table(NULL))) # structure(list(Freq = integer(0)), class = "data.frame", row.names = integer(0))
Not sure we should align to this but confirms it shouldn't error, at least
Sorry, something went wrong.
Successfully merging a pull request may close this issue.
with full
traceback()
:Probably we should return
data.table(NULL)
here.Use case: edge case of a code that was returning proper tables the rest of the time.
The text was updated successfully, but these errors were encountered: