[Rd] Another wishlist for R

Peter Dalgaard p.dalgaard at biostat.ku.dk
Mon Jan 26 15:17:01 MET 2004


Duncan Murdoch <dmurdoch at pair.com> writes:

> I like the head() and tail() functions -- nice additions.
> 
> One question:  is there a return type or class for head.function that
> would print without the quotes?  E.g.
> 
> > head(plot.default)
> [1] "function (x, y = NULL, type = \"p\", xlim = NULL, ylim = NULL, "
> [2] "    log = \"\", main = NULL, sub = NULL, xlab = NULL, ylab =
> NULL, "         
> [3] "    ann = par(\"ann\"), axes = TRUE, frame.plot = axes,
> panel.first = NULL, "
> [4] "    panel.last = NULL, col = par(\"col\"), bg = NA, pch =
> par(\"pch\"), "    
> [5] "    cex = 1, lty = par(\"lty\"), lab = par(\"lab\"), lwd =
> par(\"lwd\"), "   
> [6] "    asp = NA, ...) "     
> 
> would look nicer as
> 
> > head(plot.default)
> function (x, y = NULL, type = "p", xlim = NULL, ylim = NULL, 
>     log = "", main = NULL, sub = NULL, xlab = NULL, ylab = NULL, 
>     ann = par("ann"), axes = TRUE, frame.plot = axes, panel.first =
> NULL, 
>     panel.last = NULL, col = par("col"), bg = NA, pch = par("pch"), 
>     cex = 1, lty = par("lty"), lab = par("lab"), lwd = par("lwd"), 
>     asp = NA, ...) 
> 
> (which are the first 6 lines you see if you print plot.default).

Either setup so that cat() will be used to print it (add class + print
method) or return noquote(....) The latter will give this effect:

> noquote("function (x, y = NULL, type = \"p\", xlim = NULL, ylim = NULL, ")
[1] function (x, y = NULL, type = "p", xlim = NULL, ylim = NULL,

i.e. include line numbers.

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907



More information about the R-devel mailing list