I would write in tab-text file a table like this one: TAB colname1 TAB colname2 TAB TAB... colnameN rowname1 # # # rowname2 # # # rownameM # # # then I wrote something like: mymatrix <- matrix(nrow=M,ncol=N,byrow=T) rownames(mymatrix) <- chvector1 colnames(mymatrix) <- chvector2 write.table(mymatrix,file=myfile,sep="\t"). But I obtained: colname1 TAB colname2 TAB TAB... colnameN rowname1 # # # rowname2 # # # rownameM # # # How to put in first column a TAB ("\t")? Thanks in advance? ------------------------------------------------------------ Sincerely yours. Dr. Alessandro Semeria Tel. +39 544 536811 Models and Simulation Lab of Fax. +39 544 538663 The Environment Research Center - Montecatini (Edison Group), E-mail: asemeria at cramont.it Via Ciro Menotti 48, 48023 Marina di Ravenna (RA), Italy -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>From ?write.tableNormally there is no column name for a column of row names. If `col.names=NA' a blank column name is added. This can be used to write CSV files for input to spreadsheets. See also the `R Data Import/Export Manual', as it is in in there too. On Mon, 4 Nov 2002 AlessandroSemeria at cramont.it wrote:> I would write in tab-text file a table like this one: > > TAB colname1 TAB colname2 TAB TAB... colnameN > rowname1 # # # > rowname2 # # # > > > rownameM # # # > > then I wrote something like: > mymatrix <- matrix(nrow=M,ncol=N,byrow=T) > rownames(mymatrix) <- chvector1 > colnames(mymatrix) <- chvector2 > write.table(mymatrix,file=myfile,sep="\t"). > > But I obtained: > > > colname1 TAB colname2 TAB TAB... colnameN > rowname1 # # # > rowname2 # # # > > > rownameM # # # > > How to put in first column a TAB ("\t")?I believe rather you want a blank column before the TAB which separates columns. -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Hi, On Mon, 4 Nov 2002 AlessandroSemeria at cramont.it wrote: |I would write in tab-text file a table like this one: | |TAB colname1 TAB colname2 TAB TAB... colnameN |rowname1 # # # |rowname2 # # # I do not know any perfect solution. But you may consider: 1) add the missing tab by a text editor manually (or by a shell script). 2) If you are going to read the table later by R, then you really do not need the tab 3) write the names with the tab to the file and thereafter append the table to it. Something like write.table(c("", names.matrix), sep="\t") wirite.table(matrix, col.names=FALSE, append=TRUE) 4) write a tab to the file (eg, by write()) and thereafter append the table to it in the usual form. Perhaps it helps. Best wishes, Ott -- Ott Toomet otoomet at econ.au.dk --------------------------------------------------------- (o_ (*_ (O_ (o< -! (o<)< //\ //\ //\ //\ //\ V_/_ V_/_ V_/_ V_/_ V_/_ standard drunken shocked noisy penguin penguin penguin penguin penguin eating fish -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
I have to read myfile with excel. wirite.table(mymatrix,file=myfile, col.names=NA, append=TRUE) is not elegant but works fine. Thanks! ------------------------------------------------------------ Sincerely yours. Dr. Alessandro Semeria Tel. +39 544 536811 Models and Simulation Lab of Fax. +39 544 538663 The Environment Research Center - Montecatini (Edison Group), E-mail: asemeria at cramont.it Via Ciro Menotti 48, 48023 Marina di Ravenna (RA), Italy -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._