[R] writing a file using both cat() and paste()

From: Taka Matzmoto <sell_mirage_ne_at_hotmail.com>
Date: Thu 09 Feb 2006 - 18:26:15 EST

Hi R users

I like to create a ASCII type file using cat() and paste()

x <- round(runif(30),3)
cat("vector =( ", paste(x,sep=""), " )\n", file = "vector.dat",sep=",")

when I open vector.dat it was a long ugly file

vector =(
,0.463,0.515,0.202,0.232,0.852,0.367,0.432,0.74,0.413,0.022,0.302,0.114,0.583,0.002,0.919,0.066,0.829,0.405,0.363,0.665,0.109,0.38,0.187,0.322,0.582,0.011,0.586,0.112,0.873,0.671, )

Also there was some problems right after opening parenthesis and before the closing parenthesis. Two comma were there

I like to to have a nice formatted one like below. That is, 5 random values per a line

vector =( 0.463,0.515,0.202,0.232,0.852,


I would be appreciative if I get some help


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 Fri Feb 10 01:30:25 2006

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:42:26 EST