Hi,
Your original post suggested otherwise 
Anyway, I spent too much time trying to get this, but I wanted to see it through and found a solution that preserves the structure 
#Data
df <- list(a = list(a1 = list(1,2,3),
b1 = list("a","b","c")),
b = list(1,2,3,4,5),
c = list(a1 = list(1,2,3),
b1 = list("a","b","c"),
c1 = list("a","b", c3 = c(1,2,3))
)
)
#Recursive function that checks for numeric vaues
myFun = function(x){
if(class(x) == "list"){
#Go to next level if more dimensions
y = lapply(x, myFun)
#Ignore any NULL returns
y = y[sapply(y, function(z){
length(z) > 0
})]
return(y)
} else {
#Check for the logic
if(all(is.numeric(x))){
return(x)
}
}
}
myFun(df)
#> $a
#> $a$a1
#> $a$a1[[1]]
#> [1] 1
#>
#> $a$a1[[2]]
#> [1] 2
#>
#> $a$a1[[3]]
#> [1] 3
#>
#>
#>
#> $b
#> $b[[1]]
#> [1] 1
#>
#> $b[[2]]
#> [1] 2
#>
#> $b[[3]]
#> [1] 3
#>
#> $b[[4]]
#> [1] 4
#>
#> $b[[5]]
#> [1] 5
#>
#>
#> $c
#> $c$a1
#> $c$a1[[1]]
#> [1] 1
#>
#> $c$a1[[2]]
#> [1] 2
#>
#> $c$a1[[3]]
#> [1] 3
#>
#>
#> $c$c1
#> $c$c1$c3
#> [1] 1 2 3
Created on 2022-03-09 by the reprex package (v2.0.1)
Is this what you are looking for?
PJ