Reputation: 75
I have two vectors with different lengths in R, which contains integer number only (1,2,3,4,5). I want to plot histogram of them (in percentage, not in count) one by one.
I tried to use multhist
in the package plotrix
, but there are two problems:
It plots with y-axis
as count, not percentage.
It plots with x-axis
as float number, such as 1.1, 1.5, etc. while obviously I only need to plot with x-axis
at 1, 2, 3, 4, 5.
How could I do that in R?
Thank you very much,
Update:
the code with multhist
:
``
x1 <- round(runif(1000, 1.0, 5.0), digits=0)
x2 <- round(runif(100, 1.0, 5.0), digits=0)
require (plotrix)
multhist (x1,x2)
``
Upvotes: 0
Views: 216
Reputation: 23101
Try this:
multhist(list(x1,x2),breaks=seq(0.5,5.5,by=1),probability=TRUE)
Upvotes: 2