[R] Merging matrices of different rows

Steven Yen @tyen @end|ng |rom ntu@edu@tw
Thu Jun 26 12:46:49 CEST 2025


I'd like to cbind matrices of different number of rows, with missing values filled by "NA". I used dplyr. The following is obviously not working. Help appreciated.

> library(dplyr)
> a<-matrix(1:12,nrow=6); a
     [,1] [,2]
[1,]    1    7
[2,]    2    8
[3,]    3    9
[4,]    4   10
[5,]    5   11
[6,]    6   12
> b<-matrix(5:12,nrow=4); b
     [,1] [,2]
[1,]    5    9
[2,]    6   10
[3,]    7   11
[4,]    8   12
> cbind.fill(a,b)
Error in cbind.fill(a, b) : could not find function "cbind.fill"

Steven from iPhone
	[[alternative HTML version deleted]]



More information about the R-help mailing list