diff --git a/..Rcheck/00check.log b/..Rcheck/00check.log new file mode 100644 index 0000000000..2d743cd4d3 --- /dev/null +++ b/..Rcheck/00check.log @@ -0,0 +1,13 @@ +* using log directory ‘/Users/tanishaojha/Desktop/Code-folder/data.table/..Rcheck’ +* using R version 4.5.1 (2025-06-13) +* using platform: aarch64-apple-darwin20 +* R was compiled by + Apple clang version 16.0.0 (clang-1600.0.26.6) + GNU Fortran (GCC) 14.2.0 +* running under: macOS Sequoia 15.5 +* using session charset: UTF-8 +* checking for file ‘./DESCRIPTION’ ... ERROR +Required fields missing or empty: + ‘Author’ ‘Maintainer’ +* DONE +Status: 1 ERROR diff --git a/Makevars b/Makevars new file mode 100644 index 0000000000..dd8d74e972 --- /dev/null +++ b/Makevars @@ -0,0 +1,3 @@ +CPPFLAGS += -I/opt/homebrew/opt/gettext/include +LDFLAGS += -L/opt/homebrew/opt/gettext/lib + diff --git a/R/groupingsets.R b/R/groupingsets.R index f5fc2101f1..da0e8fe3d0 100644 --- a/R/groupingsets.R +++ b/R/groupingsets.R @@ -29,6 +29,49 @@ cube.data.table = function(x, j, by, .SDcols, id = FALSE, label = NULL, ...) { stopf("Argument 'id' must be a logical scalar.") if (missing(j)) stopf("Argument 'j' is required") + # Implementing NSE in cube + jj = substitute(j) + bysub = substitute(by) + names_x = names(x) + allbyvars = intersect(all.vars(bysub), names_x) + usesSD = any(all.vars(jj) == ".SD") + if (usesSD) { + if (missing(.SDcols)) { + ansvars = sdvars = setdiff(unique(names_x), union(by, allbyvars)) + ansvals = match(ansvars, names_x) + } else { + sub.result = substitute(.SDcols) + if (is.call(sub.result)) { + call_name = as.character(sub.result[[1L]]) + if (call_name %in% c("patterns", "is.numeric", "is.character", "is.factor")) { + .SDcols = eval_with_cols(sub.result, names_x) + } else { + .SDcols = eval(sub.result, parent.frame()) + } + } else { + .SDcols = eval(sub.result, parent.frame()) + } + if (is.character(.SDcols)) { + idx = .SDcols %chin% names_x + if (!all(idx)) + stopf("Some items of .SDcols are not column names: %s", toString(.SDcols[!idx])) + ansvars = sdvars = .SDcols + ansvals = match(ansvars, names_x) + } else if (is.numeric(.SDcols)) { + ansvals = as.integer(.SDcols) + ansvars = sdvars = names_x[ansvals] + } else if (is.logical(.SDcols)) { + if (length(.SDcols) != length(names_x)) + stopf(".SDcols is a logical vector of length %d but there are %d columns", length(.SDcols), length(names_x)) + ansvals = which(.SDcols) + ansvars = sdvars = names_x[ansvals] + } else { + stopf(".SDcols must be character, numeric, or logical") + } + } + } else { + .SDcols = NULL + } # generate grouping sets for cube - power set: http://stackoverflow.com/a/32187892/2490497 n = length(by) keepBool = sapply(2L^(seq_len(n)-1L), function(k) rep(c(FALSE, TRUE), times=k, each=((2L^n)/(2L*k))))