From p.dalgaard at biostat.ku.dk  Mon Jan 26 15:17:01 2004
From: p.dalgaard at biostat.ku.dk (Peter Dalgaard)
Date: Mon Jan 26 15:17:46 2004
Subject: [Rd] Another wishlist for R
In-Reply-To: <pq5a10pn7b6itfnkga71fbggqa6crsds1o@4ax.com>
References: <Pine.LNX.4.44.0401241416280.11292-100000@gannet.stats>
	<4012A99F.8030004@pburns.seanet.com>
	<pq5a10pn7b6itfnkga71fbggqa6crsds1o@4ax.com>
Message-ID: <x2wu7eu74y.fsf@biostat.ku.dk>

Duncan Murdoch <dmurdoch@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@biostat.ku.dk)             FAX: (+45) 35327907


[Rd] Another wishlist for R
Peter Dalgaard