I am trying to write my own function. And after some calculations for example I am obtaining a list like this ;
And according to data, number of clusters can vary from 1 to 31.
So, no matter how much the clusters are, I want to list them like the code below.
maxm5<-list(m.5$`Disaggregated rainfall depths`$`Cluster 1`, m.5$`Disaggregated rainfall depths`$`Cluster 2`...)
To perform these, I tried sapply
;
maxm5<-sapply(1:31, function(zz) list(m.5$`Disaggregated rainfall depths`$`Cluster [zz]`))
And then I tried for
loop
month<-31
maxm5<- for (i in month) {
list(m.5$`Disaggregated rainfall depths`$`Cluster [i]`)
}
But what I just got is a list with 31 null.
And then I want to give name them like;
m5.1<-maxm5[[1]]
m5.2<-maxm5[[2]] ....