Skip to content
Back to formatted view

Raw Message

Message-ID: <5.2.1.1.0.20040203171542.00b06430@mail.uark.edu>
Date: 2004-02-03T23:24:50Z
From: Bret Collier
Subject: Novice problems with write()
In-Reply-To: <200402032240.i13MeOwd002189@hypatia.math.ethz.ch>

R-Users,
         As a relatively new user of R, I have a quick (and probably 
simple) question about using write().  I have a population simulation that 
I am running and I want to output a set of variables for each run of the 
simulation into a text file for use in another program.  However, whenever 
I attempt to use write(), the only output that I am able to get is the 
final numbers from the simulation.

for example:

x <- 5
for (i in 1:10){
  z <- x+i
print(z)
write(z, "c:/test.txt")
}

In this simple case,  with print(z) I can see that z has what I am looking 
for, but all that is output for the write statement is 15;  While this is 
simplified, it shows my problem.

I searched the help files, and on the R website, but I could not find 
anything addressing this.  I suspect that it is my lack of knowledge and I 
am missing something obvious (or should be using write.table).  If anyone 
could point me in the right direction I would appreciate it.

Thanks,

Bret Collier
Univ. Arkansas