for (var_name in names(z)) { # assuming the prep function writes the content of z$var_name to the file var_name.csv prep(z, var_name) }
On Wed, Jul 1, 2015 at 10:18 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. > [[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.