I would like some assistance in changing the order subgroups appear in my forest plot. I am using the meta package in R to perform my meta-analysis and generate my forest plot. I've included some example data below.
mydata <- data.frame(
A = 1:9,
Ms = sample(100:500, 9),
Ss = sample(10:50, 9),
Mr = sample(100:500, 9),
Sr = sample(10:50, 9),
Ns = sample(5:50, 9),
Nr = sample(5:50, 9),
P = sample(c("foot", "tibia", "lumbar"), 9, replace = TRUE)
)
Here is some basic code used to run my meta-analysis.
ma <- metacont(Ns,
Ms,
Ss,
Nr,
Mr,
Sr,
data = mydata,
byvar = P,
comb.fixed = FALSE,
comb.random = TRUE)
I use the byvar function to run a subgroup analysis. Here is the code I use to plot the results.
forest(ma,
layout = "RevMan5",
subgroup = TRUE,
print.byvar = FALSE)
I would like the subgroups to be ordered foot, tibia and lumbar, rather than foot, lumbar and tibia (as shown in the link below). I'm stuck on how to do this and any help will be greatly appreciated.


