[6451] in s-news-athena

home help back first fref pref prev next nref lref last post

Re: Evaluating paramemters inside an expression

daemon@ATHENA.MIT.EDU (Rod Tjoelker 865-3197)
Wed Feb 15 16:37:57 1995

Date: Wed, 15 Feb 95 13:12:36 PST
From: Rod Tjoelker 865-3197 <tjoelker@espresso.rt.cs.boeing.com>
To: s-news@utstat.toronto.edu
Cc: bjornsto@ere.umontreal.ca


>for(i in 1:10){
>write(obji,File="c:/filei.txt")
>}
>
>Some parts of this i manage.  But in general, S-plus does not evaluate the
>expression all the places i want it to...For instance, it will always creat
>a file of the name "filei.txt" rather than file1, file2, ..., file10.



Here's a small function that creates filenames with an incremental
number and an extension.  Use the function inside your loop to create 
filenames.  The extenstion can be changed with the 'ext' argument.


  fileinc <- function(fname,i,ext=".txt") {
     paste(fname,i,ext, sep="")
  }
 
You can use it in your loop like this:

  for(i in 1:10){
   write(obji,File=fileinc("myfile",i))
  }


I hope this you find this helpful,

Rod Tjoelker

home help back first fref pref prev next nref lref last post