Re: [R] change the name of file

From: Thilo Kellermann <tkellermann_at_ukaachen.de>
Date: Mon 24 Jul 2006 - 19:34:28 EST

Dear Robert,

maybe (!) the following might do the job:

for (i in 1:50){
x<-matrix(runif(100, min=0,max=1),nrow=5,ncol=20) Write(t(x),file=paste("Data_" i ".txt", sep=""),ncolumns=5,sep="\t") }

Hope it really does...
Thilo

On Monday 24 July 2006 11:06, Robert Mcfadden wrote:
> Dear R Users,
> Is it possible to make file names dependent on a changing variable?
> For instance. I generate random numbers in a loop and at each iteration I
> want data to write to file (I do not want to write everything in one file
> using 'append'):
>
> for (i in 1:50){
> x<-matrix(runif(100, min=0,max=1),nrow=5,ncol=20)
> Write(t(x),file="Data_i.txt",ncolumns=5,sep="\t")
> }
>
> Of course file name Data_i.txt will be the same for changing i,
> unfortunately.
>
> Any suggestion would be appreciate
> Robert
>
> ______________________________________________
> R-help@stat.math.ethz.ch 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.

-- 
________________________
Thilo Kellermann
Department of Psychiatry und Psychotherapy
RWTH Aachen University
Pauwelstr. 30
52074 Aachen
Tel.: +49 (0)241 / 8089977
Fax.: +49 (0)241 / 8082401
E-Mail: tkellermann@ukaachen.de

______________________________________________
R-help@stat.math.ethz.ch 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.
Received on Mon Jul 24 21:34:12 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Mon 24 Jul 2006 - 22:19:58 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.