Skip to contents

This function takes as an argument a list. If any of its elements are also lists, it unlists them. The output is the same as the input, except that there will be one new element per element in each sublist, and the sublists will be removed.

Usage

unlistRecursive(x)

Arguments

x

A list.

Value

A list.

See also

Examples


x <- list(
   a = 1:3,
   b = list(
      b1 = c("The", "quick", "brown", "function"),
       b2 = 4:1,
      b3 = list(
         b3_1 = 5:7
      )
   ),
   c = "end"
)

unlistRecursive(x)
#> [[1]]
#> [1] 1
#> 
#> [[2]]
#> [1] 2
#> 
#> [[3]]
#> [1] 3
#> 
#> [[4]]
#> [1] "The"
#> 
#> [[5]]
#> [1] "quick"
#> 
#> [[6]]
#> [1] "brown"
#> 
#> [[7]]
#> [1] "function"
#> 
#> [[8]]
#> [1] 4
#> 
#> [[9]]
#> [1] 3
#> 
#> [[10]]
#> [1] 2
#> 
#> [[11]]
#> [1] 1
#> 
#> $b3_1
#> [1] 5 6 7
#> 
#> [[13]]
#> [1] "end"
#>