Hi,
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?
Thanks,
-tom
--
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Thomas Vogels <tov at ece.cmu.edu> writes:> Hi, > > 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?Well histograms are density estimates defined for continuous variables. What you're drawing is a barplot. barplot.factor might be a good idea, though. -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._