I am performing many permutations on a data-set with each permutation
producing a variable number of results. I thought that the best way to keep
track of all this in one object would be with a list ('res.lst'). To address
these variable results for each permutation I attempted to construct this
list using 'assign'. There is even more nesting than indicated below, but
this is a simple example that, if addressed, will fit answer my question.
The below code chunk clearly does not produce the desired results because,
instead of assigning a new vector to the list, it creates a new variable
'res.list$contrast.i.j' . In the last two lines I show what I really want to
happen. Can I use assign in this context by using it differently?

Thanks, Mark

res.lst <- list()
for (i in 1:2){
  for (j in 1:2){
    assign(paste("res.lst$contrast", i, j, sep = "."), paste(i,j,sep="."))
  }
}
res.lst

ls(pattern = "res.lst..?")

res.lst$contrast.5.5 <- 5.5
res.lst
------------------------------------------------------------
Mark W. Kimpel MD  ** Neuroinformatics ** Dept. of Psychiatry
Indiana University School of Medicine

15032 Hunter Court, Westfield, IN  46074

(317) 490-5129 Work, & Mobile & VoiceMail
(317) 399-1219  Home
Skype:  mkimpel

******************************************************************

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to