Pass 'slab' to the rma() function instead of the forest() function. Also, 'slab' is evaluated in the data frame passed via the 'data' argument, so no need to use empa$... And there is a 'subset' argument for rma(). Might as well use it. This should do it:
resultREML <- rma(yi=yi, vi=vi, method="REML", slab=paste(author, year, sep = ","), data=empa, subset=task=="x") forest(resultREML) Best, Wolfgang -- Wolfgang Viechtbauer, Ph.D., Statistician Department of Psychiatry and Psychology School for Mental Health and Neuroscience Faculty of Health, Medicine, and Life Sciences Maastricht University, P.O. Box 616 (VIJV1) 6200 MD Maastricht, The Netherlands +31 (43) 388-4170 | http://www.wvbauer.com > -----Original Message----- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] > On Behalf Of Verena Weinbir > Sent: Monday, May 26, 2014 18:57 > To: r-help > Subject: [R] Metafor: forest plot for subset > > Hey, > > I want to build a forest plot which states author and year for a subset > of > studies. > > But if I use this argument: > > resultREML <- rma(yi=yi, vi=vi, method = "REML", > data = subset(empa, task=="x")) > resultREML > > forest(resultREML, , slab=paste(empa$author, empa$year,sep = ",")) > > I get the following error message: > > Error in forest.rma(resultREML, slab = paste(EFempa$Autor, > EFempa$Jahreszahl, : > Number of outcomes does not correspond to the length of the slab > argument. > > > When I use this method without the subset function it works and I get a > forest plot stating author and year - but of course for the whole data > set, > not only for the subset "x" that I want. > > Any idea how I can make the subset function work for a forest plot with > slab function ? > > Thanks in advance! > > Verena > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting- > guide.html > and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.