prepare the output data.frame
for plotting:
Data Prep:
Keep only a combined column age_treatment
as index, I have used a comma separator, you can change in sep=" "
effect_df<-data.frame(effect_treatage)
effect_df[,1]<-paste(effect_df[,2],effect_df[,1],sep=",")
effect_df<-effect_df[,-2]
names(effect_df)[1]<-'age_treatment'
> effect_df
age_treatment fit se lower upper
1 Old,Drug 0.8232137 0.1455190 0.5174897 1.1289377
2 Old,Placebo 0.6168641 0.1643178 0.2716452 0.9620831
3 Young,Drug 0.5689036 0.1469175 0.2602413 0.8775659
4 Young,Placebo 0.7603360 0.1462715 0.4530309 1.0676410
Plot
Using ggplot2
, updated
ggplot(effect_df, aes(x=age_treatment, y=fit)) +
geom_bar(stat="identity",fill="#619CFF") +
geom_errorbar(aes(ymin=fit-se, ymax=fit+se,), width=.1,col="black") +
geom_point(aes(x=age_treatment,y=lower),size=5,shape=21)+
geom_point(aes(x=age_treatment,y=upper),size=5,shape=21)
Output