I have a huge nested list of 15 levels. i need to replace empty lists occurring at any level with chr "". I tried lapply to loop through the list but it's not working. is there any easy way to do this?
nested_list<-list(a=list(x=list(),y=list(i=list(),j=list(p=list(),q=list()))),b=list())
lapply(nested_list,function(x) if(length(x)==0) "" else x)
the lapply is being applied to only first level, how do i recursively loop the entire nested list and perform this action?