I have received help on how to create a set of lists within lists, however I have been unable to add another layer / extend the depth of my lists. All I want is to add a final 'layer' in each list, that reads, 'DataFrame', 'DataFrame2', and so on. Currently I have:
Layer1 = c('AA', 'BB', 'CC', 'DD')
myList=setNames(as.list(Layer1),Layer1)
myList=lapply(myList, function(x){
setNames(vector("list",length(Layer1)),paste0(x," vs ",Layer1))
})
Which produces myList
, containing AA
, BB
, CC
and DD
, in each of those lists is a further list e.g. AA vs BB
, AA vs BB
etc, or in the case of BB
the lists inside will read BB vs AA
, BB vs BB
(referred to hereafter as ?? vs ??
files) and so on and so forth.
So I thought I could easily add an additional layer to this by doing something along the lines of...
Layer1 = c('AA', 'BB', 'CC', 'DD')
Layer3 = c('DataFrame', 'DataFrame2', 'Matrix', 'Matrix2')
myList=setNames(as.list(Layer1),Layer1)
myList=lapply(myList, function(x){
setNames(vector("list",length(Layer1)),paste0(x," vs ",Layer1))
myList[i]=lapply(myList, function(x){
setNames(vector("list",length(Layer3)),Layer3)
})
})
Where I've naively tried to use myList[i]
(which I know won't work, but I'm not sure if anything I'm doing will) to indicate that I'd like to move down a tier and start adding blank DataFrame
and Matrix
vectors (into my ?? vs ??
sublists) so that I have 'empty slots'- so to speak - to move my data into in the future.
Ultimately I would like each ?? vs ??
folder to contain a blank DataFrame
, DataFrame2
, Matrix
, Matrix2
.