From 3c3783e3b188f79c683eb2e2df96e3f1ea3174a2 Mon Sep 17 00:00:00 2001 From: aho Date: Wed, 17 Mar 2021 17:25:08 +0100 Subject: [PATCH] Consider different dim order when finding the largest dim length --- R/Start.R | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/R/Start.R b/R/Start.R index 80e1c83..5139ac5 100644 --- a/R/Start.R +++ b/R/Start.R @@ -2260,6 +2260,17 @@ Start <- function(..., # dim = indices/selectors, # Find the longest dimensions from all the files largest_data_dims <- rep(0, length(data_dims_all_files[[1]])) + + # The inner dim order may differ among files. Need to align them before + # find out the largest dim length. + dim_names_first_file <- names(data_dims_all_files[[1]]) + same_dim_order <-lapply(lapply(data_dims_all_files, names), + identical, dim_names_first_file) + for (to_fix in which(!unlist(same_dim_order))) { + data_dims_all_files[[to_fix]] <- data_dims_all_files[[to_fix]][match(dim_names_first_file, + names(data_dims_all_files[[to_fix]]))] + } + for (kk in 1:length(data_dims_all_files[[1]])) { largest_data_dims[kk] <- max(sapply(data_dims_all_files, '[', kk)) } -- GitLab