I am using following program for saving all the barplot for a given dataset in pdf, my dataset only has categorical variables,
somePDFPath = "C:/Users/manusharma5/Documents/Rtest/graph.pdf"
pdf(file=somePDFPath)
for (colname in colnames(data2))
{
par(mfrow = c(2,1))
ggplot(data=data2, aes(x=colname))+geom_bar()+geom_text(stat='count',aes(label=..count..),vjust=-1)+
ggtitle(colname)+theme(plot.title = element_text(color="red", size=14, face="bold.italic"))
}
dev.off()
I am not able to open the pdf file, its saying there are no pages in the pdf, probably because my program is not able to produce the graphs for respective columns.
Please help me to identify the mistake I made. I appreciate all the help
And also How can I save more than 1 graph in 1 pdf page, so it will save me from 50 pdf page for 50 cat variables