Full_Name: Alexander Yephremov Version: R 2.6.2 GUI 1.23 (4932) (4932) OS: Mac OS X 10.4 Submission from: (NULL) (193.174.239.91) Hi!> array <- 0*1:50 > array[1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0> write(array, "array.file", sep=",")This is how array.file looks: 0,0,0,0,0 0,0,0,0,0 0,0,0,0,0 0,0,0,0,0 0,0,0,0,0 0,0,0,0,0 0,0,0,0,0 0,0,0,0,0 0,0,0,0,0 0,0,0,0,0 As you see, the resulting array.file is organized in 5 columns although, I think there must be a vector. It is the same with any sep. Best regards, Alexander
Hi Alexander, from the Help page of write: Usage write(x, file = "data", ncolumns = if(is.character(x)) 1 else 5, append = FALSE, sep = " ") Arguments x the data to be written out. file A connection, or a character string naming the file to write to. If "", print to the standard output connection. ncolumns the number of columns to write the data in. append if TRUE the data x are appended to the connection. sep a string used to separate columns. Using sep = "\t" gives tab delimited output; default is " ". So, set ncolumns to 1 for a one-column file. No bug AFAIKS. Regards, Hilmar efremov at mpiz-koeln.mpg.de schrieb:> Full_Name: Alexander Yephremov > Version: R 2.6.2 GUI 1.23 (4932) (4932) > OS: Mac OS X 10.4 > Submission from: (NULL) (193.174.239.91) > > > Hi! > >> array <- 0*1:50 >> array > [1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 > 0 0 0 0 0 0 0 0 0 0 0 0 >> write(array, "array.file", sep=",") > > This is how array.file looks: > > 0,0,0,0,0 > 0,0,0,0,0 > 0,0,0,0,0 > 0,0,0,0,0 > 0,0,0,0,0 > 0,0,0,0,0 > 0,0,0,0,0 > 0,0,0,0,0 > 0,0,0,0,0 > 0,0,0,0,0 > > As you see, the resulting array.file is organized in 5 columns although, I think > there must be a vector. It is the same with any sep. > Best regards, > Alexander > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel >
On 3/14/2008 6:45 AM, efremov at mpiz-koeln.mpg.de wrote:> Full_Name: Alexander Yephremov > Version: R 2.6.2 GUI 1.23 (4932) (4932) > OS: Mac OS X 10.4 > Submission from: (NULL) (193.174.239.91) > > > Hi! > >> array <- 0*1:50 >> array > [1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 > 0 0 0 0 0 0 0 0 0 0 0 0 >> write(array, "array.file", sep=",") > > This is how array.file looks: > > 0,0,0,0,0 > 0,0,0,0,0 > 0,0,0,0,0 > 0,0,0,0,0 > 0,0,0,0,0 > 0,0,0,0,0 > 0,0,0,0,0 > 0,0,0,0,0 > 0,0,0,0,0 > 0,0,0,0,0 > > As you see, the resulting array.file is organized in 5 columns although, I think > there must be a vector. It is the same with any sep.I don't see a bug. This is pretty clearly behaving as documented. By default, it sets ncolumns to 5 for non-character data. If you want it all on one line, set ncolumns to length(array). Duncan Murdoch
First of all, it's not a bug. Please don't report bugs before bringing up the "issue" on r-devel. FYI, there are people (not me), who have to go through all bug reports, tag them, and clean them out manually. If you do print(write), your concerns are answered: function (x, file = "data", ncolumns = if (is.character(x)) 1 else 5, append = FALSE, sep = " ") cat(x, file = file, sep = c(rep.int(sep, ncolumns - 1), "\n"), append = append) <environment: namespace:base> You could also have inferred that from reading help(write). Now, why there is this default rule for writing non-character values in 5 columns I don't know. There must be a historical reason for this design. Cheers /Henrik On Fri, Mar 14, 2008 at 3:45 AM, <efremov at mpiz-koeln.mpg.de> wrote:> Full_Name: Alexander Yephremov > Version: R 2.6.2 GUI 1.23 (4932) (4932) > OS: Mac OS X 10.4 > Submission from: (NULL) (193.174.239.91) > > > Hi! > > > array <- 0*1:50 > > array > [1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 > 0 0 0 0 0 0 0 0 0 0 0 0 > > write(array, "array.file", sep=",") > > This is how array.file looks: > > 0,0,0,0,0 > 0,0,0,0,0 > 0,0,0,0,0 > 0,0,0,0,0 > 0,0,0,0,0 > 0,0,0,0,0 > 0,0,0,0,0 > 0,0,0,0,0 > 0,0,0,0,0 > 0,0,0,0,0 > > As you see, the resulting array.file is organized in 5 columns although, I think > there must be a vector. It is the same with any sep. > Best regards, > Alexander > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel >