This is FAQ 7.21. The most important part of that answer is at the end where it says that it is better to use a list. Your code could be something like:
plotroc <- list() for (i in levels(mergeTrn$Continent) { # matrix defined here plotroc[[ paste("plotroc_GBM_TRN_",i, sep="") ]] <- matrix } now all of your created matrices are in the plotroc list (or whatever you want to call it) and can be operated on using functions like sapply and lapply. On Wed, Jan 30, 2013 at 1:04 AM, Kumar Mainali <kpmain...@gmail.com> wrote: > I have a situation when I need to save matrix with file names that are > programmatically created. > > for (i in levels(mergeTrn$Continent)) { > matrix here.... > > # I want to save this matrix with a file name that carries "i" from for > loop. The following does not work. > paste("plotroc_GBM_Trn_", i, sep="") <- matrix > > } > > Thanks, > Kumar > > -- > Section of Integrative Biology > University of Texas at Austin > Austin, Texas 78712, USA > > [[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. > -- Gregory (Greg) L. Snow Ph.D. 538...@gmail.com [[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.