[R] how to plot a variable's histogram in the levels of a second variable(1)

Jim Lemon jim at bitwrit.com.au
Fri Nov 14 10:45:10 CET 2008


Argyro Antaraki wrote:
> Goodmorning to everyone,
>
> I am trying to create a clustered
> barplot for the following 2 variables who have more cases but as an
> example i am giving you 10 items:
>
> sex  socio-economic status
> 1Â Â Â Â  1
> 2Â Â Â Â  2
> 2Â Â Â Â  2
> 2Â Â Â Â  3
> 2Â Â Â Â  2
> 1Â Â Â Â  4
> 1Â Â Â Â  1
> 1Â Â Â Â  1
> 2Â Â Â Â  3
> 2Â Â Â Â  1
>
> where sex: 1:man, 2:woman
> Â Â Â Â Â Â Â Â Â Â  socio-economic status:1:Low, 2:Medium, 3:High, 4:Very High
>
> Does anybody came across with a similar graph?
>   
Hi Argyro,
You may be able to use the barp function in the plotrix package. You can 
pass the output of brkdn, freq (both in the prettyR package) or table 
(in the base package) to get the correct summary values or just build a 
matrix of the values you want and pass it to barp. See the help page for 
details of how to do this.

Jim



More information about the R-help mailing list