[R] Barplot - Can't figure it out
Peter Dalgaard
p.dalgaard at biostat.ku.dk
Fri Feb 18 13:50:41 CET 2005
T Petersen <Innkeyp-r at yahoo.com> writes:
> Wow, I'm getting confused...The syntax Petr suggested does what I
> wanted, but things are stille wrong...Maybe a bug? Let me explain.
>
> I got two vectors:
>
> x = c(3, 3, 3, 4, 3, 4, 3, 4, 3, 4)
>
> y = c(5, 2, 5, 5, 2, 2, 5, 5, 4, 2)
>
> then I do the barplot you suggest
>
> barplot(rbind(table(x), table(y)), beside=T)
>
> but things are wrong(there is no bar for catagory "3") and I get an error message:
> Warning message: number of columns of result
> not a multiple of vector length (arg 1) in: rbind(table(Quest1), table(Quest2))
>
> Any ideas?
Yes. Tabulation of numerics only counts values that are present in
data (what else could it do?). Try it with table(factor(x,
levels=1:5)), etc.
--
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
More information about the R-help
mailing list