Hi all,
I'm having a bit of a brain block here. What I'm trying to do is
to store into a pointer to a matrix within a loop. This is like
using eval(parse(text="SomeName")) in a loop, but on the left
side of the assignment. If eval(parse()) evaluated to a pointer
rather than making a local copy, this would do just what I want.
More concretely, I have a series of named matrices,
myMatrix1 <- matrix(NA, nRows, nCols)
myMatrix2 <- matrix(NA, nRows, nCols)
myMatrixNames <- c("myMatrix1", "myMatrix2")
where nRows and nCols are relatively large. Now suppose I want to store
the value 100 into the [1,1] element of each of these matrices.
for (i in 1:length(myMatrixNames)) {
% this of course doesn't work, but it illustrates what I'm hoping to do.
eval(parse(text=myMatrixNames[i]))[1,1] <- 100
}
I keep thinking "C pointers", and I'm just not coming up with the Splus
logic for this kind of problem. I'd keep the matrices in a list or array,
but the total object size would then be unmanageable.
Thanks in advance,
Steve
---
Steven M. Boker 219-631-4941 (voice)
sboker@nd.edu 219-631-8883 (fax)
http://www.nd.edu/~sboker/ 219-257-2956 (home)
Dept. of Psychology, University of Notre Dame, Notre Dame, IN 46556
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news
|