From Martin Maechler <maechler@stat.math.ethz.ch>  Wed Jun 19 17:06:55 2002
From: Martin Maechler <maechler@stat.math.ethz.ch> (Martin Maechler)
Date: Wed, 19 Jun 2002 18:06:55 +0200
Subject: .. add an argument to suppress printing of levels for print.factor()?
In-Reply-To: <871yd7jsjh.fsf@jeeves.blindglobe.net>
References: <871yd7jsjh.fsf@jeeves.blindglobe.net>
Message-ID: <15632.44063.277697.883795@gargle.gargle.HOWL>

>>>>> "tony" == A J Rossini <rossini@blindglobe.net> writes:

on April 22 --- you see I'm cleaning up pending e-mails :-)

    tony> could we add an argument to suppress printing of levels for
    tony> print.factor()?  i.e.:


    tony> print.factor <-
    tony> function (x, quote = FALSE, print.levels = TRUE, ...)    ## MODIFIED
    tony> {
    tony>  if (length(x) <= 0)
    tony>  cat("factor(0)\n")
    tony>  else print(as.character(x), quote = quote, ...)
    tony>  if (print.levels) {                                         ## ADDED
    tony>    cat("Levels: ", paste(levels(x), collapse = " "), "\n")
    tony>  }                                                           ## ADDED
    tony>  invisible(x)
    tony> }

    tony> I've done this for my local work, but wondering if this is useful in
    tony> general?

As I said then, it is useful idea, thank you Tony.

However, as I just found out,  S+6.0 does it a bit better.
Their  print.factor() has a  'max.levels = 5' argument which
allows more than just on/off.

Here's S+6.0 help(print.factor) :

>>                         Use print() on a factor object
>>                                        
>> USAGE:
>> 
>> print.factor(x, quote = F, abbreviate.arg, ..., max.levels = 5)
>> 
>> REQUIRED ARGUMENTS:
>> 
>>    x
>>           The factor object to print
>>           
>> OPTIONAL ARGUMENTS:
>> 
>>    quote
>>           If quote is TRUE then the strings in the factors will be
>>           surrounded by quotes and all the levels will be printed.
>>           
>>    max.levels
>>           If some of the levels in a factor object are not in represented
>>           in the object (or if quote is TRUE), then the first max.levels
>>           levels will be printed.
>>           This is a method for the function print() for objects
>>           inheriting from class factor.


Hence we are waiting for a new patch  (:-)

Martin
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


.. add an argument to suppress printing of levels for print.factor()?
Martin Maechler