[R] Histogram for factors

Thomas Vogels tov at ece.cmu.edu
Fri Jan 12 20:15:02 CET 2001


I keep running into this:
R> hist (f)
Error in hist.default(f) : `x' must be numeric

To which of course something like (simplified but not beyond repair):
R> hist.factor <- function (ff) {
  jj <- table (ff)
  jb <- barplot (jj, ylab="Frequency", xlab=deparse(substitute(ff)))
  axis (1, jb, names (jj))
R> hist (f)
is a possible solution.

Why is a 'hist.factor' not part of the base distribution?  Is this
kind of thing discouraged?  Usually not needed?  Am I missing sth else?


mailto:tov at ece.cmu.edu (Tom Vogels)   Tel: (412) 268-6638   FAX: -3204

r-help 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-help-request at stat.math.ethz.ch

More information about the R-help mailing list