[R] sample

foobar wwsprague at ucdavis.edu
Wed May 5 20:56:56 CEST 2004


> 
> 	Every time I want to repeat this I have to change the name of *.txt 
> file manually. How can I automate this, so it could be done for all the  
> *.txt files (1000) I have to generate.

Use something like:

for (i in 1:1000){
   name = paste('foo_', i, '.txt', sep='')

You can figure out how to apply that idea.

You can also refer to a variable by its name in string form, like

a = get(paste('varname', i, sep=''))

paste is your friend!

W




More information about the R-help mailing list