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

Martin Maechler Martin Maechler <maechler@stat.math.ethz.ch>
Wed, 19 Jun 2002 18:06:55 +0200


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