I have a problem when combining the following vectors included in the list:
x <- list(as.numeric(c(1,4)),as.numeric(c(3,19,11)))
names (x[[1]]) <- c("species.A","species.C")
names (x[[2]]) <- c("species.A","species.B","species.C")
which gives the following list:
>x >[[1]] >species.A species.C > 1 4 >[[2]] >species.A species.B species.C > 3 19 11
combining them using the do.call function:
y<- do.call(cbind,x)
gives:
>y > [,1] [,2] > species.A 1 3 > species.B 4 19 > species.C 1 11
while I would like to obtain this:
> [,1] [,2] > species.A 1 3 > species.B NA 19 > species.C 4 11
do.call(cbind, lapply(x, '[', spp))
– Guaranty