Re: [R] write.table & csv help

From: Petr Pikal <petr.pikal_at_precheza.cz>
Date: Tue 27 Jun 2006 - 19:44:27 EST


Hi

I am not sure about what you want to achieve by sequential writing to a file so maybe you could fill an object in a loop and write it only once.

df<-data.frame(matrix(nrow=4,ncol=2))
for(i in seq(1:2))
{
 df[,i] <- rnorm(4, mean=0, sd=1)
}
write.table(df,"output.csv", quote = FALSE, sep = ",", row.names = FALSE, col.names = TRUE)

HTH
Petr

From: Sachin J <sachinj.2006_at_yahoo.com> Date: Tue 27 Jun 2006 - 04:34:36 EST

Hi,

  How can I produce the following output in .csv format using write.table function.

  for(i in seq(1:2))
{
 df <- rnorm(4, mean=0, sd=1)
 write.table(df,"C:/output.csv", append = TRUE, quote = FALSE, sep = ",", row.names = FALSE, col.names = TRUE) }

  Current O/p:

              x 0.287816 -0.81803 -0.15231 -0.25849 x 2.26831 0.863174 0.269914 0.181486

Desired output

              x1 x2 0.287816 2.26831 -0.81803 0.863174 -0.15231 
0.269914 -0.25849 0.181486     

  Thanx in advance     

  Sachin                   



----------------------------------------------------------------------

        [[alternative HTML version deleted]]



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 Petr Pikal
petr.pikal@precheza.cz



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 Received on Tue Jun 27 19:48:32 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 Tue 27 Jun 2006 - 22:12:28 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.