[R] (no subject)

Tanvir Khan tkhan1 at isrt.ac.bd
Fri Sep 10 11:38:35 CEST 2010


Hello,
I'm trying to do bar plot where 'sex' will be the category axis and
'occupation' will represent the bars and the clusters will represent
the mean 'income'.

   sex     occupation   income
1  female          j             12
2    male          b            34
3    male          j             22
4  female          j            54
5    male          b           33
6  female          b           67
7    male          j            89
8    male          b          65
9  female          j          45
10   male          j          32

I can do bar plot where sex is the category axis and the clusters
represent 'occupation'.
the code is-

> t<- table(data$sex,data$occupation)
> barplot(f)

and the barplot where the category axis is 'sex' and the cluster
represent the mean income and median income. The code is -
> mean=tapply(data$income,data$sex,mean)
> mean
  female     male
38.66667 46.50000
> median=tapply(data$income,data$sex,median)
> median
female   male
  22.5   49.5
> r=rbind(mean,median)
> r
               female     male
mean    38.66667     46.5
median 22.50000    49.5
> par(fg='red',cex=1.2)
> barplot(r,col=c('green','yellow'),cex.axis=1.2,col.axis='red',ylim=c(0,120)

But how can I make 'occupation'' to nest inside 'sex' and then the
cluster to represent the mean income?
For example I am attaching a pdf plot that is produced by SPSS.

Thank you.


-- 
Tanvir Khan
MS Student
Institute Of Statistical Research & Training
University Of Dhaka
tkhan1 at isrt.ac.bd
khan.tanvir_007 at ymail.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OUTPUT.pdf
Type: application/pdf
Size: 2744 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20100910/91d91f81/attachment.pdf>


More information about the R-help mailing list