- for (i in 2:nobj)
- if (all(rownames(obj[[i]]) %in% nms))
- obj[[i]] <- obj[[i]][nms, ]
- else stop("rownames do not match among matrices.")
+ nms <- unlist(lapply(obj, rownames))
+ if (fill.with.gaps) {
+ NC <- unlist(lapply(obj, ncol))
+ nms <- unique(nms)
+ ans <- matrix(as.raw(4), length(nms), sum(NC))
+ rownames(ans) <- nms
+ from <- 1
+ for (i in 1:n) {
+ to <- from + NC[i] - 1
+ tmp <- rownames(obj[[i]])
+ nmsi <- tmp[tmp %in% nms]
+ ans[nmsi, from:to] <- obj[[i]][nmsi, , drop = FALSE]
+ from <- to + 1
+ }
+ } else {
+ tab <- table(nms)
+ ubi <- tab == n
+ nms <- names(tab)[which(ubi)]
+ ans <- obj[[1]][nms, , drop = FALSE]
+ for (i in 2:n)
+ ans <- cbind(ans, obj[[i]][nms, , drop = FALSE])
+ if (!quiet && !all(ubi))
+ warning("some rows were dropped.")
+ }
+ } else {
+ if (length(unique(NR)) > 1)
+ stop("matrices do not have the same number of rows.")
+ ans <- matrix(unlist(obj), NR)
+ rownames(ans) <- rownames(obj[[1]])