i using r, , sourcing script within 1 master script. within sourced script, have code looks following:
pdf("figs/bar_gni.pdf") m1table$country1 <- reorder(m1table$country, m1table$gnipc2005) ggplot(m1table, aes(y=gnipc2005, fill=level)) + geom_bar(aes(x=country1), data=m1table, stat="identity") + coord_flip() + ggtitle("gni per capita, 2005") + xlab("country") + ylab("gni per capita, atlas method (current us$)") dev.off()
the important part, if i'm correct, i'm opening pdf graphics device, making plot, , closing device.
when run source script (by opening script), works fine. however, when source it, none of graphs outputted. seems create files, creates blank files.
any feedback appreciated.
ggplot graphics plotted when objects printed.
on command line happens when type in. typing sqrt(2)
prints answer because command line automatically calls print
, doing ggplot(.)+geom_line(.)
calls print
, makes plot.
in script, results aren't auto-printed.
so wrap ggplot
calls print(ggplot(whatever))
.
this r faq. http://cran.r-project.org/doc/faq/r-faq.html#why-do-lattice_002ftrellis-graphics-not-work_003f
Comments
Post a Comment