It looks like you want a "flat" list. For this, you can use unlist
with recursive = FALSE
, but depending on how deep the list is, that might be tedious. Here's an example:
Your data:
myList <- list(list(a = list("1" = letters[1:3], "2" = letters[1:4])),
list(a = list("1" = letters[1:3], "2" = letters[1:4])))
myList
# [[1]]
# [[1]]$a
# [[1]]$a$`1`
# [1] "a" "b" "c"
#
# [[1]]$a$`2`
# [1] "a" "b" "c" "d"
#
#
#
# [[2]]
# [[2]]$a
# [[2]]$a$`1`
# [1] "a" "b" "c"
#
# [[2]]$a$`2`
# [1] "a" "b" "c" "d"
Using nested unlist
s:
unlist(unlist(myList, recursive=FALSE), recursive=FALSE)
# $a.1
# [1] "a" "b" "c"
#
# $a.2
# [1] "a" "b" "c" "d"
#
# $a.1
# [1] "a" "b" "c"
#
# $a.2
# [1] "a" "b" "c" "d"
There is also this nifty function called LinearizeNestedList (https://sites.google.com/site/akhilsbehl/geekspace/articles/r/linearize_nested_lists_in_r) that can be downloaded/sourced in R and used as follows (for lists of any depth of nesting):
LinearizeNestedList(myList, NameSep=".")
# $`1.a.1`
# [1] "a" "b" "c"
#
# $`1.a.2`
# [1] "a" "b" "c" "d"
#
# $`2.a.1`
# [1] "a" "b" "c"
#
# $`2.a.2`
# [1] "a" "b" "c" "d"
Edit
It appears this question is a duplicate of How to flatten a list to a list without coercion?
See that question and set of answers for other useful solutions.