Skip to content
Prev 42526 / 398506 Next

assign

On Wed, 7 Jan 2004, Perez Martin, Agustin wrote:

            
Actually, you assigned ten times to object x.j. As was mentioned earlier 
today in reference to a different question, you will almost always find 
that what you think you need and what works best are not the same - a list 
here would be much more convenient:

x <- vector(mode="list", length=10)
for (j in 1:10) {
  x[[j]] <- rnorm(100)
}

for example. For more complicated list elements, the arguments for using 
lists are even stronger. Take a little time to make lists your friends, 
they are powerful and flexible.