[R] creating files using for loop
Brian Quinif
bquinif at gmail.com
Fri Apr 7 06:02:32 CEST 2006
I would like to use a for loop to run estimations on 12 different
subsets of a dataset.
I have the basics of my script figured out, but I am having problems
getting the loop to name some files as I would like. Here is a
sketch of my code:
sub.dataset <- c(101, 201)
#Assume I only have two subsets which I call 101 and 201
for (i in 1:length(sub.dataset)) {
#Estimation commands here...unimportant for this question
#Estimates <- matrix of estimation resultsI will write out to LaTeX
latex(Estimates, file=sub.dataset[i].tex)
}
So, the latex command is what's problematic here. How can I get my
for loop to put file='101.tex' and file='201.tex' (or many similar
things) where I want it to. I could just as easily want to put
something like 101$variable1 or 201$variable1.
Sorry for such a basic question regarding for loops, but thanks for the help.
Brian
More information about the R-help
mailing list