0

Is there any way to unlist in R flattening in a row wise way?

i.e if my list were

[[1]]
     [,1]   [,2]
[1,] "2498" "A" 
[2,] "2346" "B" 
[3,] "2073" "B" 
[4,] "404"  "C" 

Flatten the list to:

"2498", "A" ,"2346" ,"B" ,"2073" ,"B" "404" , "C" 

Instead of what happens in a call to unlist :

"2498" "2346" "2073" "404"  "A"    "B"    "B"    "C" 

dput of data:

list(structure(c("2498", "2346", "2073", "404", "A", "B", "B", 
"C"), .Dim = c(4L, 2L)))
user124123
  • 1,642
  • 7
  • 30
  • 50
  • `c(t(lst[[1]]))` – Ronak Shah Jul 11 '19 at 04:18
  • @RonakShah This approach doesn't unlist. – user124123 Jul 11 '19 at 04:20
  • It does "unlist" but doesn't use the function `unlist`. It gives you the expected output shown in the post. If that is not what you want can you make your question more clear and show an example where this approach fails? If you have got lists of lists then you might need to use `sapply`, `c(sapply(lst, t))` – Ronak Shah Jul 11 '19 at 04:21

0 Answers0