I have two square matrices where both of them have some missing data. I want to pad the missing data with NA in the two matrices
Data below:
#first matrix
t1 = matrix(
c(1, 0, 1, 0, 0, 1, 1, 0, 1),
nrow = 3,
ncol = 3,
byrow = TRUE
)
rownames(t1) <- c("a","b", "c")
colnames(t1) <- c("a","b", "c")
#second matrix
t2 = matrix(
c(1, 1, 0, 0, 0, 1, 0, 0, 1),
nrow = 3,
ncol = 3,
byrow = TRUE
)
rownames(t2) <- c("a","c", "d")
colnames(t2) <- c("a","c", "d")
#Expected outcome for the two matrices:
#first matrix
a b c d
a 1 0 1 NA
b 0 0 1 NA
c 1 0 1 NA
d NA NA NA NA
#second matrix
a b c d
a 1 NA 1 0
b NA NA NA NA
c 0 NA 0 1
d 0 NA 0 1
How do I achieve this? Preferrably the outcome is a list that contains these two NA-padded matrices