I wrote a function in R that, if I could pass by reference, would work as I intend. It involves nesting sapply calls and performing assignment inside them. Since R does not use pass by reference, the functions don’t work.
I am aware that there are packages available such as R.oo to bring pass by reference-y aspects to R, but I would like to learn if there is a better way. What is the ‘R’ way of passing data if pass by reference is not available?
If you don’t modify an argument then it won’t actually copy it so it may be pointless to do anything special:
EDIT: minor changes to example