diff --git a/R/Start.R b/R/Start.R index 80e1c83d869f45cfc6228078329d87f1816d7bb7..5139ac5cb301f532dd9e5b59e162e1e3cc42e796 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)) }