1

I have a list with different vector length:

 [[1]]
 X1  X2 
"N" "N" 

[[2]]
 X1  X2 
"N" "C" 

[[3]]
 X1  X2 
"S" "S" 

[[4]]
 X1  X2  X3 
"S" "S" "U" 

[[5]]
NULL

[[6]]
 X1  X2 
"S" "N" 

[[7]]
 X1  X2  X3 
"S" "S" "S" 

[[8]]
 X1  X2 
"S" "N" 

[[9]]
 X1  X2  X3  X4  X5  X6 
"F" "S" "S" "S" "N" "C" 

What I am trying to accomplish is to cbind equal length vectors together, to be like this, for 3 length vectors:

   [,1] [,2] 
X1 "S"  "S"  
X2 "S"  "S"  
X3 "U"  "S"

Same goes for other length vectors, such as 2:

 [,1] [,2] [,3] [,4] [,5]
X1 "N"  "N"  "S"  "S"  "S"
X2 "N"  "C"  "S"  "N"  "N"

Thank you in advance.

  • 3
    `lapply(split(L, lengths(L)), do.call, what = cbind)` maybe. Hard to know since you didn't provide an easily reproduced example. – Frank Apr 18 '18 at 19:53
  • Hello, I apologize for the lack of information. Can you tell me what I need to add / provide so it is easier to be answer? Thanks in advance. – Satria Arief Wicaksono Bakri Apr 19 '18 at 07:00
  • Sure, I meant that you should provide code that reproduces the example input (so we can copy-paste it into a new R session and see the same thing). Some guidance: https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example/28481250#28481250 – Frank Apr 19 '18 at 11:15

0 Answers0