I'm trying to build graphs in a PDF format from the output from my R script. I'm using the knit2PDF package to do this.
When I have more than one data point to plot it plots fine. Eg:
However, when there is only data point the graph looks something like this
Here's the code im using :
plot.new()
par(mar=c(2,0,0,0))
par(xpd=T, mar=par()$mar+c(0,0,0,4))
bplot= barplot(p[c("Control","Exposed"),], col=c("#0078E8","#FF9900"),
beside=T,names.arg=paste(paste(colnames(p),sep = " "),
paste("Control:", p["Control_count",], sep=" "),
paste("Exposed:", p["Exposed_count",], sep= " ")
,sep="\n"),
cex.names=0.4, width = 0.5, axes=F, border=F,space=c(0,1),ylim=c(0,max(p[c("Control","Exposed"),]+10)))
Is there a way I can control the look of the graph automatically when there is one data point ?