guido-s / meta

Official Git repository of R package meta
http://cran.r-project.org/web/packages/meta/index.html
GNU General Public License v2.0
82 stars 32 forks source link

leftcols #19

Closed badgettrg closed 4 years ago

badgettrg commented 4 years ago

Summary

When left columns are specified with leftcols, three problems occur

  1. The columns after middle-aligned and I cannot find a way to left-align
  2. The columns have two decimal places and I cannot find a way to remove the decimal places without also removing the decimal places for the effect size in the right columns
  3. The labels and calculations for subgroups are not displayed
data(Olkin95)

Olkin95$modern <- ifelse(Olkin95$year>1980 , 'Modern', 'Old')

meta1 <- metabin(event.e, n.e, event.c, n.c,subset=20:27,
                 data=Olkin95, sm="RR",
                 studlab=paste(author, year), byvar = modern)
# Default, without leftcols, looks ok
meta::forest(meta1, comb.fixed=TRUE, comb.random=FALSE)
# Specifying leftcols creates problems
meta::forest(meta1, comb.fixed=TRUE, comb.random=FALSE,
       leftcols=c('author','year'))

Thanks very much for your time and the meta package.

guido-s commented 4 years ago

Hi,

Ad 1. R function forest.meta() has a certain set of predefined columns shown in a forest plot (see help page, under Details). The columns author and year do not belong to this set of columns and are accordingly additional columns. By default, additional columns are middle-aligned. You can use argument just.addcols (or just.addcols.left and just.addcols.right) to change the alignment of additional columns.

Ad 2. Argument digits.addcols (or digits.addcols.left and digits.addcols.right) can be used to change the number of decimal places for additional columns. However, with meta, version 4.9-9, additional columns do not show any decimal place if the column contains integers (like the column year).

Ad 3. In order to show labels and results for subgroups, the column studlab must be present on the left side of the forest plot.

Please have a look at the following examples:

# Use argument 'just.addcols'
forest(meta1, comb.random = FALSE,
       leftcols = c('author', 'year'), just.addcols = c('left', 'center'))

# Print (correct) study labels contained in "studlab"
forest(meta1, comb.random = FALSE,
       leftcols = c("studlab", "year"), leftlabs = c("Author", "Year"),
       print.byvar = FALSE, colgap.left = "2.25cm")

# Change study labels to author name
forest(update(meta1, studlab = author), comb.random = FALSE,
       leftcols = c("studlab", "year"), leftlabs = c("Author", "Year"),
       print.byvar = FALSE, colgap.left = "2.25cm")
badgettrg commented 4 years ago

Solved by your comment, "the column studlab must be present on the left side."

Thanks much

guido-s commented 2 years ago

Finally fixed, new code for meta, version 5.0 and above:

data(Olkin95)

Olkin95$modern <- ifelse(Olkin95$year>1980 , 'Modern', 'Old')

meta1 <- metabin(event.e, n.e, event.c, n.c, subset=20:27,
  data=Olkin95, sm="RR",
  studlab=paste(author, year),
  subgroup = modern, random = FALSE)

# Default, without leftcols
forest(meta1)

# Specifying leftcols without "studlab" also works now

forest(meta1, leftcols=c('author', 'year'), addrows = 2)