diff --git a/R/as.data.table.R b/R/as.data.table.R index a706aecb86..9d286d7f16 100644 --- a/R/as.data.table.R +++ b/R/as.data.table.R @@ -102,7 +102,7 @@ as.data.table.array = function(x, keep.rownames=FALSE, key=NULL, sorted=TRUE, va dnx } else dnx val = rev(val) - if (is.null(names(val)) || all(!nzchar(names(val)))) + if (is.null(names(val)) || !any(nzchar(names(val)))) setattr(val, 'names', paste0("V", rev(seq_along(val)))) if (value.name %chin% names(val)) stop("Argument 'value.name' should not overlap with column names in result: ", brackify(rev(names(val)))) diff --git a/R/data.table.R b/R/data.table.R index c070f7dcb6..0a0efd326d 100644 --- a/R/data.table.R +++ b/R/data.table.R @@ -1116,7 +1116,7 @@ replace_dot_alias = function(e) { lhs = names_x[m] } else stop("LHS of := isn't column names ('character') or positions ('integer' or 'numeric')") - if (all(!is.na(m))) { + if (!anyNA(m)) { # updates by reference to existing columns cols = as.integer(m) newnames=NULL diff --git a/R/xts.R b/R/xts.R index 121f36f1bd..31c5ad2309 100644 --- a/R/xts.R +++ b/R/xts.R @@ -19,7 +19,7 @@ as.xts.data.table = function(x, ...) { stopifnot(requireNamespace("xts"), !missing(x), is.data.table(x)) if (!xts::is.timeBased(x[[1L]])) stop("data.table must have a time based column in first position, use `setcolorder` function to change the order, or see ?timeBased for supported types") colsNumeric = vapply_1b(x, is.numeric)[-1L] # exclude first col, xts index - if (any(!colsNumeric)) warning("Following columns are not numeric and will be omitted: ", brackify(names(colsNumeric)[!colsNumeric])) + if (!all(colsNumeric)) warning("Following columns are not numeric and will be omitted: ", brackify(names(colsNumeric)[!colsNumeric])) r = setDF(x[, .SD, .SDcols = names(colsNumeric)[colsNumeric]]) return(xts::as.xts(r, order.by = if ("IDate" %chin% class(x[[1L]])) as.Date(x[[1L]]) else x[[1L]])) }