A.J. Rossini
2002-Apr-22 22:08 UTC
[Rd] could we add an argument to suppress printing of levels for print.factor()?
could we add an argument to suppress printing of levels for print.factor()? i.e.: print.factor <- function (x, quote = FALSE, print.levels = TRUE, ...) ## MODIFIED { if (length(x) <= 0) cat("factor(0)\n") else print(as.character(x), quote = quote, ...) if (print.levels) { ## ADDED cat("Levels: ", paste(levels(x), collapse = " "), "\n") } ## ADDED invisible(x) } I've done this for my local work, but wondering if this is useful in general? best, -tony -- A.J. Rossini Rsrch. Asst. Prof. of Biostatistics U. of Washington Biostatistics rossini@u.washington.edu FHCRC/SCHARP/HIV Vaccine Trials Net rossini@scharp.org -------------- http://software.biostat.washington.edu/ ---------------- FHCRC: M-W: 206-667-7025 (fax=4812)|Voicemail is pretty sketchy/use Email UW: Th: 206-543-1044 (fax=3286)|Change last 4 digits of phone to FAX (my friday location is usually completely unpredictable.) -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
A.J. Rossini
2002-Jun-19 16:04 UTC
[Rd] could we add an argument to suppress printing of levels for print.factor()?
>>>>> "martin" == Martin Maechler <maechler@stat.math.ethz.ch> writes: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 -- A.J. Rossini Rsrch. Asst. Prof. of Biostatistics U. of Washington Biostatistics rossini@u.washington.edu FHCRC/SCHARP/HIV Vaccine Trials Net rossini@scharp.org -------------- http://software.biostat.washington.edu/ ---------------- FHCRC: M: 206-667-7025 (fax=4812)|Voicemail is pretty sketchy/use Email UW: Th: 206-543-1044 (fax=3286)|Change last 4 digits of phone to FAX (my tuesday/wednesday/friday locations are completely unpredictable.) -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 Maechler
2002-Jun-19 16:06 UTC
.. add an argument to suppress printing of levels for print.factor()?
>>>>> "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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._