🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by dcford Mon, 01 Aug 2005 07:31
creating data objects using loop index
#221
Author: dcford
Date: Mon, 01 Aug 2005 07:31
25 lines
1701 bytes
Hi,

  I am trying to create matrices on the fly and call them later in
order to save some time.  I realize that for loops in S aren't that
efficient but humor me:

for(i in 1:10) {
     object[i]<-A%*%B
}

clearly this isn't creating a new matrix each time
I'd like to have matrix1, matrix2, matrix3...etc created once the loop
completes.  Is there a way to dynamically name and create data objects?

Additionally I'd like to be able to call those matrices later for
example:

for(i in 1:10){
     for(j in 1:10)
    final.matrix<-sum(object[i] * object[j])
}}

I want object[i] and object[j] to represent the names of matrices
created earlier. Is there a way to create a reference like this.
Any suggestions are greatly apprecieated
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads