Colorful Funnel Plots: A Guide to Plotting byvar with pch

To plot funnel plots with different color classes for each byvar, you can use the pch argument in the funnel() function from the meta package.

Here is an example:

library(meta)

# assuming m1 is a metabin object

meta::funnel(m1, 
             pch = as.numeric(as.factor(m1$byvar)), 
             main = "w/ pch")

In this example, as.numeric(as.factor(m1$byvar)) converts the factor variable m1$byvar to a numeric vector. This is necessary because the pch argument expects a numeric value.

By using as.numeric(as.factor(...)), we ensure that the color classes are correctly assigned to each byvar, even if they don’t have the same number of levels.


Last modified on 2025-02-27