Thank you so much for replying me! for better understanding my problem, I explain my problem more:
I have a 682*1 matrix called "met" , the first 5 rows similar below: > rownames(met)[1:5] [1] "glycine_imp" [2] "Nacetylglycine_imp" [3] "sarcosine_imp" [4] "dimethylglycine_imp" [5] "betaine_imp" and I have a function in R that each time use one of the row names of "met" matrix and create a new object file and I should save the objects! my function is " Scores(Z=metalofGT,formula="met[i]~egfr_v1_ckdepi+pc1+pc2+pc3+V1AGE01+GENDER") " that each time just I should change the met[i] and replace by row names "met" one by one and for each of them I should rename the function and after that I should save each object! for example for first row of "met" I have > prep1<- > Scores(Z=metalofGT,formula="glycine_imp~egfr_v1_ckdepi+pc1+pc2+pc3+V1AGE01+GENDER") #creat the object file for first row and called prep1### > save(prep1, file="prep1.RData", compress="bzip2") ##save the object file as "prep1.RData"##### I should do this process for 682 row names of "met" matrix and at the end I should have "prep1.RData" , "prep2.RData" , "prep3.RData" so, would you please help me how to do it? Many Thanks, Ati On Wed, Jul 1, 2015 at 1:07 PM, Lida Zeighami <lid.z...@gmail.com> wrote: > I have 682 variables in a data frame , and a function that I should feed > 682 variables in this function one by one and each time save the file as a > special name! > for emaple: > my data frame file includes 682 names : > 1 aaa > 2 bbb > 3 dfdsfg > 4 fghh > . > > 682 fgfhg > and a function like prep(Z, aaa, .....) and each time I should change the > variable name in this function and read the variable from the data frame > and each time I should save the file as a special name such as: > > prep1<- prep(z, aaa,...) > prep2<- prep(z, bbb,...) > prep3<- prep(z, dfdsfg,..) > Prep4<- prep(z, fghh,...) > > How can I use loop function in R to that? > > Thanks > [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.