Skip to content

change codes into loops

6 messages · zhijie zhang, David Winsemius, Simon Knapp

#
On Jan 18, 2010, at 7:19 PM, rusers.sh wrote:

            
There is no correct method. You cannot index on the object name b_nn  
that way. R has not been developing using a syntax with that much  
flexibility.  If you want a 3D array of values, then you could create  
b_ijn[i, j, nn] and make assignments to it. But if you tried to do  
this with paste and assign, you will spending considerably more time  
degbugging it than it is worth and it would likely be more inefficient  
than what you have.
#
On Jan 18, 2010, at 7:58 PM, David Winsemius wrote:

            
I take that back.
You could make  a list of matrices:

for (nn in 1:3) {
     bn[[nn]] <- b[i,j] <- rank(c(a1[i,j]:a3[i,j]))[nn]
# assuming that your right hand construction is meaningful,,,,  
impossible to tell without an example.
}
David Winsemius, MD
Heritage Laboratories
West Hartford, CT