I have a simple recursion function in R that would modify its input arguments. I use eval.parent(substitute()) in order to apply the changes on the arguments, However I get this error: "invalid (do_set) left-hand side to assignment " Does anyone know how to fix this error? Here is my function:
decompose_clade=function(ind,Small_clades_ind,Remove_tips,Clades){ Ch=Children(tree,ind) if(Ch[1]<length(tree$tip.label)){ l=Remove_tips l=c(l,Ch[1]) eval.parent(substitute(Remove_tips=l)) print("tip added=") print(Ch[1]) }else if(length(extract.clade(tree,Ch[1])$tip.label)<4){ s=Small_clades_ind s=c(s,Ch[1]) eval.parent(substitute(Small_clades_ind=s)) print("small clade added=") print(Ch[1]) }else if(length(extract.clade(tree,Ch[1])$tip.label)>80){ decompose_clade(Ch[1],Small_clades_ind,Remove_tips,Clades) print("function calls again") }else{ m=Clades m=c(m,Ch[1]) eval.parent(substitute(Clades<-m)) print("a clade added=") print(Ch[1]) } }