[R] Suppress 'x' when appending to a csv file

Marc Schwartz marc_schwartz at comcast.net
Sat Sep 8 18:12:47 CEST 2007


On Sat, 2007-09-08 at 11:41 -0400, John Kane wrote:
> Is there any convenient way to supress the x that
> appears in csv export files?  I would like to be able
> to export a file and add a comment to it yet still be
> able to read it back into R.  I don't see any way to
> get rid of the x that seperates the different appended
> parts.
> 
> Thanks
> 
> EXAMPLE
> 
> x
> 1
> 2
> 3
> 4
> 5
> x
> #Results from file SSS.r
> 
> R.2.5.1 Windows XP

John,

Try this:

> write.table(head(iris), sep = ",", 
              row.names = FALSE, col.names = FALSE)
5.1,3.5,1.4,0.2,"setosa"
4.9,3,1.4,0.2,"setosa"
4.7,3.2,1.3,0.2,"setosa"
4.6,3.1,1.5,0.2,"setosa"
5,3.6,1.4,0.2,"setosa"
5.4,3.9,1.7,0.4,"setosa"


You may need to explicitly adjust other arguments that are otherwise set
to defaults when using write.csv().

HTH,

Marc Schwartz



More information about the R-help mailing list