diff --git a/R/NcToArray.R b/R/NcToArray.R index fc4b438a475b0348eebab3da4640983d1549e520..7bb13b6888e25b4bc811992384be5edc6651c0d0 100644 --- a/R/NcToArray.R +++ b/R/NcToArray.R @@ -223,7 +223,7 @@ NcToArray <- function(file_to_read, dim_indices = NULL, vars_to_read = NULL, reorder_back <- NULL indices_dims <- names(dim_indices)[which(names(dim_indices) %in% names(dim(var_result)))] if (length(indices_dims) > 0) { - if (any(names(dim(var_result))[-which(names(dim(var_result)) %in% names(extra_dims))] != indices_dims)) { + if (any(setdiff(names(dim(var_result)), names(extra_dims)) != indices_dims)) { reorder_back <- 1:length(dim(var_result)) dims_to_reorder <- which(!(names(dim(var_result)) %in% names(extra_dims))) reorder_back[dims_to_reorder] <- dims_to_reorder[sapply(indices_dims,