[R] write.table & csv help
Petr Pikal
petr.pikal at precheza.cz
Tue Jun 27 11:44:27 CEST 2006
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 at 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 at precheza.cz
More information about the R-help
mailing list