Skip to content

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

4 messages · Martin Maechler, A.J. Rossini

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

In order to do that, I need to know what abbreviate.arg (the
"un-documented" argument) does.  Anyone know?    Other thant that,
it (the patch) is almost ready.

(yes, I'm silly -- I'd rather not fire up S-PLUS 6 when doing reverse
engineering...). 

best,
-tony
#
martin> Hence we are waiting for a new patch  (:-)

    a> In order to do that, I need to know what abbreviate.arg (the
    a> "un-documented" argument) does.  Anyone know?    Other thant that,
    a> it (the patch) is almost ready.

    a> (yes, I'm silly -- I'd rather not fire up S-PLUS 6 when doing reverse
    a> engineering...). 

And here's the hack; note that I've left my "argument" in for
backwards compatibility.

"print.factor" <- 
  function (x, quote = FALSE, max.levels=5, print.levels = {if
(max.levels==0) FALSE else TRUE}, ...)
{ 
  if (length(x) <= 0) 
    cat("factor(0)\n") 
  else print(as.character(x), quote = quote, ...) 
  if (print.levels) {
    cat("Levels: ", paste(levels(x)[1:max.levels], collapse = " "),
"\n")
  }
  invisible(x) 
} 

It's ugly but seems to work.

best,
-tony
#
martin> Hence we are waiting for a new patch (:-)

    a> In order to do that, I need to know what abbreviate.arg
    a> (the "un-documented" argument) does.  Anyone know?  Other
    a> thant that, it (the patch) is almost ready.

    a> (yes, I'm silly -- I'd rather not fire up S-PLUS 6 when
    a> doing reverse engineering...).

    tony> And here's the hack; note that I've left my "argument"
    tony> in for backwards compatibility.

    ....

hmm, are you serious ?
I mean it's not a very good reason to introduce an extra
argument, not S back-compatible, just because you had a local
hack with it?

I'm about to do the version withOUT the `print.levels'.

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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
martin> Hence we are waiting for a new patch (:-)

    a> In order to do that, I need to know what abbreviate.arg
    a> (the "un-documented" argument) does.  Anyone know?  Other
    a> thant that, it (the patch) is almost ready.

    a> (yes, I'm silly -- I'd rather not fire up S-PLUS 6 when
    a> doing reverse engineering...).

    tony> And here's the hack; note that I've left my "argument"
    tony> in for backwards compatibility.

    martin>     ....

    martin> hmm, are you serious ?

Actually, I am, since I'll keep it as my local version :-).  Note that
this is backwards compatible to a historic point (my April email :-).

    martin> I mean it's not a very good reason to introduce an extra
    martin> argument, not S back-compatible, just because you had a local
    martin> hack with it?

I think that's sensible (for others and R :-).

    martin> I'm about to do the version withOUT the `print.levels'.

And that is fine.  Something needs to be fixed with respect to the
abbreviate.arg; I think that there is a better way.

best,
-tony