new version of print.factor
A.J. Rossini
rossini@u.washington.edu
19 Jun 2002 12:32:12 -0700
Thanks to Tony Plate for letting me know what the abbreviate.arg
option does. I think this could be made more flexible (I.e.
=TRUE, =FALSE, =#, where # would be passed to the abbreviate
min.length argument). But it follows the example I was given.
"print.factor" <-
function (x, quote = FALSE, max.levels=5, print.levels = {if
(max.levels==0) FALSE else TRUE}, abbreviate.arg=FALSE, ...)
{
if (length(x) <= 0)
cat("factor(0)\n")
else print(as.character(x), quote = quote, ...)
if (print.levels) {
if (abbreviate.arg) {
cat("Levels: ", paste(abbreviate(levels(x)[1:max.levels]),
collapse = " "), "\n")
} else {
cat("Levels: ", paste(levels(x)[1:max.levels],
collapse = " "), "\n")
}
}
invisible(x)
}
It definitely could be cleaned up a bit more.
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._