On 09/13/2013 12:48 AM, Moshiur Rahman wrote:
Hi R-helpers,

Can anyone help me to give hints/packages to make a simple bar plot with
mean and standard error of variables (A, C&  F) that I'd like to plot in X
and the values in Y? The factor (sex) should be as legend (Male&  Female).
Actually, I'd prefer to have a plot like the attached Fig.

data:     Sex    A   C   F
1   Male  3.4 1.1 8.6
2   Male  6.1 2.4 0.1
3   Male   NA 0.7 0.8
4 Female 12.2  NA 0.6
5 Female  3.4 2.2 0.1
6 Female  3.5 2.4 2.7


Hi Moshi,
Your example didn't come through, but I will take a guess:

mrdat<-read.table(text="Sex    A   C   F
Male  3.4 1.1 8.6
Male  6.1 2.4 0.1
Male   NA 0.7 0.8
Female 12.2  NA 0.6
Female  3.4 2.2 0.1
Female  3.5 2.4 2.7",header=TRUE)
mmeans<-sapply(mrdat[1:3,2:4],mean,na.rm=TRUE)
fmeans<-sapply(mrdat[4:6,2:4],mean,na.rm=TRUE)
mfmeans<-matrix(c(mmeans,fmeans),nrow=2,byrow=TRUE)
barpos<-barplot(mfmeans,names.arg=c("A","C","F"),
 col=c("lightblue","pink"),beside=TRUE,
 main="Barplot",ylim=c(0,10))
library(plotrix)
mserrs<-sapply(mrdat[1:3,2:4],std.error,na.rm=TRUE)
fserrs<-sapply(mrdat[4:6,2:4],std.error,na.rm=TRUE)
mfserrs<-matrix(c(mserrs,fserrs),nrow=2,byrow=TRUE)
dispersion(barpos,mfmeans,mfserrs)
legend("top",c("Male","Female"),fill=c("lightblue","pink"))

Note that this plot and the one requested in your previous post are likely to attract negative comment.

Jim

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to