[R] write.table: last line should differ from usual eol
Andreas Gegg
AndreasGegg at gmx.de
Sat Jun 9 12:31:03 CEST 2007
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)
More information about the R-help
mailing list