R-alpha: generic write()
Ross Ihaka
ihaka@stat.auckland.ac.nz
Mon, 26 May 1997 07:54:59 +1200 (NZST)
Kurt Hornik writes:
> Attached is a first shot at a generic write with my `old' write.table as
> write.data.frame, suitably modified. There is also a stupid generic
> latex function, which is just there because it illustrates that the
> extra arguments sep and eol are useful.
>
> In playing with it, I noticed a few `problems'.
>
> * The documentation for factor() says,
>
> If exclude is set to a zero length vector, then any NA values in
> x are used for form a new level for the factor. This means that
> there will be no NA values in the result.
>
> Perhaps I don't really understand this, but
>
> R> x <- factor(c(1:3, NA), exclude=numeric(0))
> R> x
> [1] 1 2 3 NA
> R> levels(x)
> [1] "1" "2" "3"
Looks like a bug to me ...
> * coerce.c has two error messages of the form
>
> error("use \"factor\", \"ordered\", \"cut\" or \"code\" to create factors\n");
>
> but there is no function `code'.
A VERY old (pre- 0.1) error message
> * cat() is a bit inconsistent:
>
> R> cat(x, sep = "&")
> 1&2&3&4R> cat(x, sep = "&\n")
> 1&
> 2&
> 3&
> 4
> R>
>
> Actually, a final newline is added whenever sep contains a newline.
> >From src/main/builtin.c:
>
> nlsep = 0;
> for (i = 0; i < LENGTH(sepr); i++)
> if (strstr(CHAR(STRING(sepr)[i]), "\n")) nlsep = 1;
>
> ...
>
> if ((pwidth != INT_MAX) || nlsep)
> Rprintf("\n");
>
> I am not sure this is the right thing to do.
>
> (In particular, it makes it rather messy to incrementally build data
> files with `explicit' end-of-line strings (such as "\\") by appending
> via cat().)
I will look at this a bit more (and compare with the AT&T prototype).
Ross
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
r-devel 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-devel-request@stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-