[R-meta] [metafor package] How to use italics on one section of a forest plot

Viechtbauer, Wolfgang (SP) wolfg@ng@viechtb@uer @ending from m@@@trichtuniver@ity@nl
Mon Jun 25 16:14:51 CEST 2018


That's a creative solution :) I like it!

Best,
Wolfgang

-----Original Message-----
From: Alexandre Palaoro [mailto:alexandre.palaoro using gmail.com] 
Sent: Monday, 25 June, 2018 15:02
To: Viechtbauer, Wolfgang (SP)
Cc: r-sig-meta-analysis using r-project.org
Subject: Re: [R-meta] [metafor package] How to use italics on one section of a forest plot

Dear Wolfgang,

Thanks for the reply! That worked nicely.

A friend of mine also found another solution that may be helpful to other users. The code is below.

Best wishes,
Alexandre

# Creating a vector with species names
##spp <- c("S. proximum", "I. pustulosa", "N. maximus") 
 
# Creating a command to use expression and paste()
order <- paste("expression(italic('", spp, "'))", sep="")
order
 
# Using sapply and eval(parse()) to generate a list of expressions
ital <- sapply(ordem, function(x){eval(parse(text=x))}) 

# Use the ital object in forest()
forest(res, slab = ital) 

On Mon, Jun 25, 2018 5:38 AM, Viechtbauer, Wolfgang (SP) wolfgang.viechtbauer using maastrichtuniversity.nl wrote:
Dear Alexandre, 
How about something like this: 
dat <- escalc(measure="RR", ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat.bcg) 
res <- rma(yi, vi, data=dat) 
forest(res, slab=NA) 
text(par()$usr[1], 13:1, dat$author, pos=4, font=3) 
Best, 
Wolfgang 
-----Original Message----- 
From: R-sig-meta-analysis [mailto:r-sig-meta-analysis-bounces using r-project.org] On Behalf Of Alexandre Palaoro 
Sent: Tuesday, 12 June, 2018 19:39 
To: r-sig-meta-analysis using r-project.org 
Subject: [R-meta] [metafor package] How to use italics on one section of a forest plot 
Dear All, 
I want to make a forest plot with subgroups using the forest() function of the 
'metafor' package. 
My code and potential plot is much similar to the one provided in the metafor 
doku page 
(http://www.metafor-project.org/doku.php/plots:forest_plot_with_subgroups), but 
with one simple difference: 
The "Author(s) and Year" column (figure below) is going to be replaced by a list 
of species names, and instead of a plain font, I want all species names to be in 
italics. In my code, I plotted the species names using the 'slab' argument, as 
the code below shows. 
forest(res.rma.mv,xlim=c(-10,9),ylim=c(3,108), ilab=ilab.text, 
ilab.xpos=c(-6,-4.5,-3),       slab=expression(italic(data$species.name)), 
       pch=21,bg=alpha("black",0.75),efac=0.2,cex=1) 
I tried using the expression(italic()) function (and all its variants), but I 
always get the same error, regardless of which argument I use ('slab' or 
'ilab'). 
Error in forest.rma(res.rma.mv, xlim = c(-10, 9), ylim = c(3,108), ilab = 
expression(italic(random$sp)), : Number of outcomes does not correspond to the 
length of the 'ilab' argument. In addition: Warning message: In is.na(ilab) : 
is.na() applied to non-(list or vector) of type 'expression' 
Does any one know how to work around this? 
Best wishes,Alexandre 
--Alexandre Varaschin Palaoro, Dr.LAGE do Departamento de EcologiaUniversidade 
de São Paulo, Brazilhttp://alexandrevpalaoro.eco.br 
Blog Sobrevivendo na Ciênciahttps://marcoarmello.wordpress.com/


More information about the R-sig-meta-analysis mailing list