> library(MASS)
> d=anorexia
> Outcome=ifelse(d$Postwt>d$Prewt,1,0)
> d1=cbind(d,Outcome)
> d2=d1[which(d1$Treat=="Cont"),]
> d3=d1[which(d1$Treat=="CBT"),]
> d4=d1[which(d1$Treat=="FT"),]
> s1=sum(d2$Outcome);s2=sum(d3$Outcome);s3=sum(d4$Outcome)
> s=c(s1,s2,s3)
> S=c(dim(d2)[1],dim(d3)[1],dim(d4)[1])
> b1=barplot(as.matrix(t(cbind(s,S))),xlab = "trt")
> b1
[1] 0.7 1.9 3.1
Get Answers For Free
Most questions answered within 1 hours.