I have written code to compute multi-indices in R [1] and due to the recursive nature of the computation I need to pass around the *same* matrix object (where each row corresponds to one multi-index). As pass by reference wasn't the default behavior I declared a global matrix (mat) and used the <<- operator to write to the global matrix. So the usage would be to call genMultiIndices(3,2) for side effects to generate all multi-indices of length 3 and sum 2. And then access the global matrix.
However, after coding this I can't seem to export the global matrix object (in the NAMESPACE file) and still retain mutability since its binding is "locked" (R throws an error). Can I somehow unlock this? Ideally I would want to pass around the same matrix to the recursive function. Is that possible? If not, could someone please suggest a workaround to use the code in an R package? [1]: http://dpaste.com/209186/ ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.