Learn R Programming

forestplot (version 1.0)

fpColors: A function for the color elements used in forestplot()

Description

This function encapsulates all the colors that are used in the forestplot function. As there are plenty of color options this function gathers them all in one place.

Usage

fpColors(all.elements, box = "black", lines = "gray", summary = "black",
  zero = "lightgray", text = "black", axes = "black")

Arguments

all.elements
A color for all the elements. If set to NULL then it's set to the par("fg") color
box
The color of the box indicating the estimate
lines
The color of the confidence lines
summary
The color of the summary
zero
The color of the zero line
text
The color of the text
axes
The color of the x-axis at the bottom

Value

  • list A list with the elements:
  • boxthe color of the box/marker
  • linesthe color of the lines
  • summarythe color of the summary
  • zerothe color of the zero vertical line
  • textthe color of the text
  • axesthe color of the axes

Details

If you have several values per row in a forestplot you can set a color to a vector where the first value represents the first line/box, second the second line/box etc. The vectors are only valid for the box & lines options. This function is a copy of the meta.colors function in the rmeta package.

See Also

Other forestplot.functions: forestplot; fpDrawCircleCI, fpDrawDiamondCI, fpDrawNormalCI, fpDrawPointCI, fpDrawSummaryCI; fpLegend

Examples

Run this code
ask <- par(ask=TRUE)

# An example of how the exponential works
test_data <- data.frame(coef=c(2.45, 0.43),
                        low=c(1.5, 0.25),
                        high=c(4, 0.75),
                        boxsize=c(0.5, 0.5))
row_names <- cbind(c("Name", "Variable A", "Variable B"),
                   c("HR", test_data$coef))
test_data <- rbind(rep(NA, 3), test_data)

forestplot(labeltext = row_names,
           test_data[,c("coef", "low", "high")],
           is.summary=c(TRUE, FALSE, FALSE),
           boxsize   = test_data$boxsize,
           zero      = 1,
           xlog      = TRUE,
           col = fpColors(lines="#990000", box="#660000", zero = "darkblue"),
           new_page = TRUE)

par(ask=ask)

Run the code above in your browser using DataLab