Hi, I've been reading the Data Import and Export manual (page 25 on Connection chapter) but somehow I can't manage to get what I want. I have a 28x28 distance matrix, which I would like to export to a file. What I did was something like: zz <- file("ex.data", "w") # open an output file connection cat( traffic.manDist, file = zz ) # traffic.manDist is my matrix name close(zz) But instead of exporting the matrix, it export each number in the matrix and separating each number into one line! Can anyone tell me where I did wrong? Much appreciated! Cheers, Kevin ---------------------------------------------------------------- Ko-Kang Kevin Wang Statistical Analysis Division Leader Software Developers' Klub University of Auckland New Zealand -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Ko-Kang at xtra.co.nz wrote:> > Hi, > > I've been reading the Data Import and Export manual (page 25 on Connection > chapter) but somehow I can't manage to get what I want. > > I have a 28x28 distance matrix, which I would like to export to a file. > What I did was something like: > zz <- file("ex.data", "w") # open an output file connection > cat( traffic.manDist, file = zz ) # traffic.manDist is my matrix name > close(zz) > > But instead of exporting the matrix, it export each number in the matrix and > separating each number into one line! > > Can anyone tell me where I did wrong? Much appreciated!Have a look at ?write and ?write.table. Uwe -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Wed, 2 May 2001 Ko-Kang at xtra.co.nz wrote:> Hi, > > I've been reading the Data Import and Export manual (page 25 on Connection > chapter) but somehow I can't manage to get what I want.(page numbers depend on your formatting: I get page 25 in an index.)> I have a 28x28 distance matrix, which I would like to export to a file. > What I did was something like: > zz <- file("ex.data", "w") # open an output file connection > cat( traffic.manDist, file = zz ) # traffic.manDist is my matrix name > close(zz) > > But instead of exporting the matrix, it export each number in the matrix and > separating each number into one line!If you mean that all the numbers appear on one line separated by spaces, that's what cat() does given a matrix: you got what you asked for. Try it at the console.> Can anyone tell me where I did wrong? Much appreciated!If you want to export a matrix to a text file, read the section on `export to text files', which is way before page 25. -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, 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 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._