[R] Symbolic derivation using D in package stats - how do I properly convert the returned call into a character string?

Peter Dalgaard p.dalgaard at biostat.ku.dk
Tue Nov 21 16:38:01 CET 2006


Duncan Murdoch <murdoch at stats.uwo.ca> writes:

...
> The problem is that deparse() has a maximum line width of around 500 
> characters, and you need more to fit your entire expression on one line, 
> the way paste is trying to do.
> 
> I suppose we could increase the buffer size in deparse (or make it 
> dynamic), but I'm not sure that it's worthwhile.  Why would you want to 
> use paste on a long expression like that?  Why not leave it as an 
> expression?  deparse() works fine to print it on multiple lines; I'm 
> just not sure I see the value in allowing arbitrarily long lines here.

and dividing two expressions is much easier done using code like this:

> e1 <- expression(a+b)
> e2 <- expression(c+d)
> substitute(a/b,list(a=e1[[1]],b=e2[[1]]))
(a + b)/(c + d)


> fortune("parse")

If the answer is parse() you should usually rethink the question.
   -- Thomas Lumley
      R-help (February 2005)



> (At a minimum, I think paste() should report a "line too long" error 
> rather than silently truncating; I'm not saying the current behaviour is 
> fine.)

(I suspect there are so many cases where things get truncated that an
error message would drive users up the wall...)

-- 
   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)                  FAX: (+45) 35327907



More information about the R-help mailing list