[Rd] as.data.frame: Error in "names<-.default" (PR#7808)

ripley at stats.ox.ac.uk ripley at stats.ox.ac.uk
Wed Apr 27 19:21:43 CEST 2005


On Sun, 24 Apr 2005 andy_liaw at merck.com wrote:

[...]

>> f <- function(x) deparse(substitute(x))
>> f(FUN(x1[1:3,,], x2=c("a","b"), x3=c("a", "b"), x4=c("a", "b")))
> [1] "FUN(x1[1:3, , ], x2 = c(\"a\", \"b\"), x3 = c(\"a\", \"b\"), x4 =
> c(\"a\", "
> [2] "    \"b\"))"
>
>
> which is caused by deparse() chopping up the expression.  The fix would be
> to set the width.cutoff argument to something large.  Here's a proposed
> patch:

[...]

> (I used width.cutoff=500, as ?deparse says that the max.  I'd imagine the
> number of characters allowed for valid symbol names in R is probably lower
> than that?)

This is an expression, and can be arbitrarily long.  So one needs to do 
things like terms.formula:

         else paste(deparse(form[[2]]), collapse = "")

or just use the initial part (as done elsewhere).

It's fixed in R-patched now.

-- 
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 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-devel mailing list