diff --git a/R/Start.R b/R/Start.R index 964d52f2426f1f0c331f9883df8b53144b1dbf16..1251634b83286f0cabc6af45dffe63c14ea05019 100644 --- a/R/Start.R +++ b/R/Start.R @@ -2670,9 +2670,8 @@ Start <- function(..., # dim = indices/selectors, selector_indices_to_take <- which(selector_file_dim_array == j, arr.ind = TRUE)[1, ] names(selector_indices_to_take) <- names(selector_file_dims) selector_store_position[names(selector_indices_to_take)] <- selector_indices_to_take - #TODO: Check if the non-subset part makes sense. "selector_indices_to_take" is an array if - # "selector_file_dims" is not 1 (if selector is an array with a file_dim dimname, ie., - # time = [sdate = 2, time = 4]. + # "selector_indices_to_take" is an array if "selector_file_dims" is not 1 (if + # selector is an array with a file_dim dimname, i.e., time = [sdate = 2, time = 4]. if (!is.null(names(selector_indices_to_take))) { sub_array_of_selectors <- Subset(selector_array, names(selector_indices_to_take), as.list(selector_indices_to_take), drop = 'selected') @@ -2697,8 +2696,14 @@ Start <- function(..., # dim = indices/selectors, } else { if (length(names(var_file_dims)) > 0) { var_indices_to_take <- selector_indices_to_take[which(names(selector_indices_to_take) %in% names(var_file_dims))] - sub_array_of_values <- Subset(var_with_selectors, names(var_indices_to_take), - as.list(var_indices_to_take), drop = 'selected') + if (!is.null(names(var_indices_to_take))) { + sub_array_of_values <- Subset(var_with_selectors, names(var_indices_to_take), + as.list(var_indices_to_take), drop = 'selected') + } else { + # time across some file dim (e.g., "file_date") but doesn't have + # this file dim as dimension (e.g., time: [sdate, time]) + sub_array_of_values <- var_with_selectors + } } else { sub_array_of_values <- var_with_selectors }