I have an asymmetric list, i.e., the number of elements in each sub-list differ. How can I convert the list to a matrix?
Below I begin with a symmetric list and con
First, extend each vector in your list with NAs to get vectors of the same length. Then create your matrix. For example:
max.len <- max(sapply(my.list2, length)) corrected.list <- lapply(my.list2, function(x) {c(x, rep(NA, max.len - length(x)))}) mat <- do.call(rbind, corrected.list)