[Rd] write function (PR#10953)

Henrik Bengtsson hb at stat.berkeley.edu
Fri Mar 14 15:54:46 CET 2008


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
>



More information about the R-devel mailing list