I am trying to populate a set of matrices in which the names of the matrices (objects) are stored in a list. I can use get () to return the object with the given name, but when I use get () to determine the matrix, the object I'm trying to fill is.
#Create list of matrix names: list.names <- c("m.1")
So, in the last line of code, I get an error:
could not find function "get <-"
Similarly, I can call m.1 using:
eval(as.name(list.name[1]))
But R returns a similar error "could not find function" when I try to fill the matrix.
Can someone explain the error in my approach here?
Change / Update:
Therefore, trying to simplify the issue for publication here, I realized that maybe I simplified what I'm trying to do.
So, actually, I'm trying to populate the elements in a matrix set. Matrix names are contained in the list.names object. I use nested for () loops to populate each element in the matrices.
So, in fact, my problem will be more accurately indicated as:
get(list.names[1])[1,1] <- some_value
Several answers suggested using an assignment based on my original post, but given that I'm trying to “assign” an element within an object, not the whole object, this approach will not work.
Sorry for the confusion.