dear friends - I have a problem in ggplot2 which I hope you can help me understand and solve.

Running windows 7, R 3.2.1

grp <- gl(3,4,12)
trt <- gl(4,1,12)
num <- c(11,1,0,0,6,2,0,0,1,9,10,10)
MM <- data.frame(grp=grp,num=num,trt=trt)
levels(MM$grp)<- c("anest1","anest2","anest3")
levels(MM$trt)<- c("drug1","drug2","drug3","drug4")

ggplot(data=MM)+ geom_bar(mapping=aes(x=grp,y=num),fill=trt,stat="identity") +
theme(legend.position="top") + ylab("Number")+xlab("")

How do Imake ggplot make a label? - I tried to annotate("text",1,5,"drug1") returning

mapping: x = x, xmin = xmin, y = y
geom_text: na.rm = FALSE
stat_identity: na.rm = FALSE

so that was not as I thought. How do I get the label directly - or annotate if that is the only possibility?

Best wishes

Troels Ring

______________________________________________ mailing list -- To UNSUBSCRIBE and more, see
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.

Reply via email to