[R] metagen - plotStudySizes: order by year and not alphabetical

Antonello Preti antoviral at gmail.com
Sat May 30 14:01:28 CEST 2015


HI everybody.
I'm using the package 'metagen' to plot sample size in meta-analysis.
The plot function of the package reorders the studies by alphabetcial order.
However, I would like to have the studies listed by year.
How can I force the plotting function to order the study by the variable
'year' rather than by the first initial of the variable 'reference'?

Thank you in advance,
Antonello

Here my sample code:


### the data

df <- structure(list(reference = structure(c(3L, 6L, 9L, 2L, 8L, 5L,
7L, 10L, 4L, 1L), .Label = c("Bellani et al. 2012             ",
"Bocco et al. 2004              ", "Costa 1998          ",
"Dalla Volta et al. 2011           ", "Manzanere et al. 2006             ",
"McEnty et al. 2001             ", "Ossian et al. 2006                ",
"Simone et al. 2004               ", "Tanter et al. 2002         ",
"Zimmian et al. 2006              "), class = "factor"), size = c(20,
288, 70, 138, 475, 191, 918, 80, 508, 205), year = c(1998, 2001,
2002, 2004, 2004, 2006, 2006, 2006, 2011, 2012)), .Names = c("reference",
"size", "year"), class = "data.frame", row.names = c(NA, -10L
))

### a quick look at the data

head(df)
str(df)

### the library

library(metagen); library(ggplot2)

### the plot

p1 <- plotStudySizes(df)
p1 <- p1 + ggtitle("Studies with Cross-sectional estimates")
p1

	[[alternative HTML version deleted]]



More information about the R-help mailing list