Carrie
Carrie

Reputation: 31

Getting an R code error when trying to create a Forest Plot

I am using the following code in R to build a Forest Plot:

library(forestplot)

    cochrane_from_rmeta <-
  structure(list(
    mean  = c(NA, NA, 1.62, 1.48, 1.43, 1.55, 1.60, 1.63, 1.48, 1.43, 1.43, 1.41, NA),
    lower = c(NA, NA, 1.23, 0.95, 1.04, 1.15, 1.01, 1.83, 1.15, 1.04, 1.07, 0.79, NA),
    upper = c(NA, NA, 2.14, 2.31, 1.95, 2.09, 2.53, 5.68, 1.91, 1.95, 1.92, 2.54, NA)),
    .Names = c("mean", "lower", "upper"),
    row.names = c(NA, -13L),
    class = "data.frame")

    tabletext<-cbind(
  c("", "Subgroup", "RRMS", "<40 years-old",
    "≥ 40 years-old", "Female", "Male", "First-Line",
    "Non First-Line", "Baseline GdE Lesions","No Baseline GdE Lesions",
    "Direct Switch from NTZ", NA),
  c("Discontinuation", "(DMF)", "244", "93",
    "233", "238", "88", "27",
    "299", "63", "240","41", NA),
  c("Discontinuation", "(FTY)", "148", "62",
    "124", "137", "49", "7",
    "179", "32","138","57", NA),
  c("", "OR", "1.62", "1.48",
    "1.43", "1.55", "1.60", "1.63",
    "1.48", "1.43", "1.43", "1.41", NA))

    forestplot(tabletext,
           cochrane_from_rmeta,new_page = TRUE,
           is.summary=c(TRUE,TRUE,rep(FALSE,10),TRUE),
           clip=c(0.1,2.5),
           xlog=TRUE,
           col=fpColors(box="royalblue",line="darkblue", summary="royalblue"))

When I do this, I get the following error:

"Error in prFpConvertMultidimArray(mean) :
  Sorry did not manage to correctly identify the upper/lower boundaries from the input matrix”

Any ideas on how to adjust my code so that the error is fixed?

Thanks in advance, Carrie

Upvotes: 3

Views: 806

Answers (1)

Tung
Tung

Reputation: 28451

You need to specify the mean, lower and upper parameters

    forestplot(tabletext,
                   cochrane_from_rmeta$mean,
                   cochrane_from_rmeta$lower,
                   cochrane_from_rmeta$upper,
                   new_page = TRUE,
                   is.summary=c(TRUE,TRUE,rep(FALSE,10),TRUE),
                   clip=c(0.1,2.5),
                   xlog=TRUE,
                   col=fpColors(box="royalblue",line="darkblue", summary="royalblue"))

enter image description here

Upvotes: 1

Related Questions