Hi,
I don't see any answers to this, so let me offer a few suggestions.
Do you call dev.off() at the end of your plotting code? That seems
most likely, since you omit it here.
If that doesn't solve your problem:
What OS and version of R are you using?
If you use the default device for your OS does the plot appear in a
device window?
Can you use the png() device for other graphics, ie does:
png("testplot.png")
plot(1:10)
dev.off()
produce a plot?
Start there: with more information we're more likely to be able to
help you. A reproducible example would be excellent: we don't have
your data so we can't run your code. Using built-in datasets or dput()
with a section of your data are both good options for creating
reproducibility.
Sarah
On Sat, Aug 3, 2013 at 3:50 AM, wanjiku gichohi <wngichohi at gmail.com>
wrote:> Hi All,
>
> I am quite new to R so my question may seem a bit basic.
>
> I run the below syntax to create a forest plot with sub group analyses.
>
> The forest plot does not display though when I look at the console I see no
> error message.
>
> What could be the problem?
>
>
> ### to save as png file
> png(filename="forest_plot_with_subgroups.png",
> res=95, width=680, height=680, type="cairo")
>
> ### decrease margins so the full space is used
> par(mar=c(4,4,1,2))
>
> ### load BCG vaccine data
> syntax <-read.csv(file="I:/ext drive/PhD Wageningen/review-iron
metabolism
> and snps/new R files/new_rs855791 by HB.csv", header=TRUE,
sep=",", dec=".")
> View(syntax)
>
> ### fit random-effects model (use slab argument to define study labels)
> res <- rma.uni(yi=Beta, sei=SE,
data=syntax,slab=paste(Author,"(",Year,")",
> sep=""), method="REML")
>
> ### to specify exactly in which rows the outcomes will be plotted)
>
forest(syntax.reml,xlab="Beta",xlim=c(-2,1.5),ylim=c(-2,24),order=order(syntax$Ethnicity),showweight=FALSE,efac=3,cex=.9)
> op <- par(font=2)
> text(-16, c(11,5,2), pos=4,
c("Caucasian","Asian","Mixed"))
> text(-16, 26, "Author and Year", pos=4)
> text(10, 26, "N", pos=2)
> text(6, 26, "Beta[SE]", pos=2)
> par(op)
> op <- par(cex=.75, font=4)
> res.s <- rma.uni(yi=Beta, sei=SE,
>
data=syntax,subset=(Ethnicity=="Caucasian"),method="REML")
> res.r <- rma.uni(yi=Beta, sei=SE,
> data=syntax,subset=(Ethnicity=="Asian"),method="REML")
> res.a <- rma.uni(yi=Beta, sei=SE,
> data=syntax,subset=(Ethnicity=="Mixed"),method="REML")
> addpoly(res.s, row=18.5, cex=.75, atransf=FALSE, mlab="RE Model for
> Subgroup")
> addpoly(res.r, row= 7.5, cex=.75, atransf=FALSE, mlab="RE Model for
> Subgroup")
> addpoly(res.a, row= 1.5, cex=.75, atransf=FALSE, mlab="RE Model for
> Subgroup")
>
> --
> Wanjiku N Gichohi
>
--
Sarah Goslee
http://www.functionaldiversity.org