[R] which data structure to choose to keep multile objects?

clue_less suhai_tim_liu at yahoo.com
Sat Nov 7 00:58:10 CET 2009


I have a function called nnmf which takes in one matrix and  returns two
matrices. for example, 

> X
     [,1] [,2] [,3] [,4]
[1,]    1    4    7   10
[2,]    2    5    8   11
[3,]    3    6    9   12

> z=nnmf(X,2)

> z$W
          [,1]      [,2]
[1,] 0.8645422 0.6643681
[2,] 1.7411863 0.5377504
[3,] 2.6179287 0.4111063
> z$H
           [,1]     [,2]     [,3]     [,4]
[1,] 1.14299486 1.692260 2.241279  2.79030
[2,] 0.01838514 3.818559 7.619719 11.42087

----------------------------------------

Now I would like to run it many times --

z2 = nnmf(X,2)
z3 = nnmf(X,3)
z4 = nnmf(X,4)
z5 = nnmf(X,5)
...

But I would like to do it automatically , something like -
 
xprocess<-function(max_val) {
   for (iter in  2: max_val) {
      
      zz = sprintf( "z%s", iter )
 
      zz <-nnmf(X,iter)
  
   }

}

xprocess(10)
 

----

But how could I keep collection of my results each run?

Shall I have a data structure to keep appending results?

something like 

theta = {}

?

which data structure to choose to keep multile objects?

Thanks!

Tim

-- 
View this message in context: http://old.nabble.com/which-data-structure-to-choose-to-keep-multile-objects--tp26231601p26231601.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list