[R] plot categorical variable with percentage infomation

Jie jimmycloud at gmail.com
Mon Aug 26 18:27:08 CEST 2013


Dear All,

Suppose I have a categorical variable
a=as.factor(sample(1:3,10,replace=T))

plot(a) and hist(as.numeric(a),freq=F) would give the histogram of it.
But I do not know how to add the counts or percentage information for
plot.factor().
hist() can do it but as a numeric variable, the x-axis is not 3
categories in this case.
Thank you for any suggestion.

Best wishes,
Jie



More information about the R-help mailing list