[R] write.table: last line should differ from usual eol

From: Andreas Gegg <AndreasGegg_at_gmx.de>
Date: Sat, 09 Jun 2007 12:31:03 +0200


Dear R-Team,

I have a problem with writing an array to (for example) a .txt-file. Because of the .txt-file must be read from another programm (OPL ILOG), the syntax of the output must be from a special form:

name_of_the_object = [	[1,2, ... ],
			[1,...],
			... ];

I think it's easier to understand with a small example:

X<-array(1:4,c(2,2))

should be written as:
X = [[1,3],

      [2,4]];

I have (until now) used the following:

write("X=[[",file=filename)
write.table(X,file=filename,sep=",",eol="],\n [", row.names=FALSE, col.names=FALSE,append=TRUE)

which leads to the following output:
X=[[
1,3],
[2,4],
[

I hope you can help because it's very annoying to adjust the resulting .txt-file "by hand".

Thanks a lot for your help!
With nice greetings

Andreas Gegg,
mathematic-student on Catholic University of Eichstätt-Ingolstadt (Germany)



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 and provide commented, minimal, self-contained, reproducible code. Received on Sat 09 Jun 2007 - 10:37:42 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 09 Jun 2007 - 11:31:45 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.