longarm | R Documentation |
This function transforms data from pairwise comparisons to a long arm-based format, i.e., two rows for a pairwise comparison.
longarm(
treat1,
treat2,
event1,
n1,
event2,
n2,
mean1,
sd1,
mean2,
sd2,
time1,
time2,
data = NULL,
studlab,
id1 = NULL,
id2 = NULL,
append = TRUE,
keep.duplicated = FALSE,
keep.internal = FALSE
)
treat1 |
Either label for first treatment or a meta-analysis or pairwise object (see Details). |
treat2 |
Label for second treatment. |
event1 |
Number of events (first treatment). |
n1 |
Number of observations (first treatment). |
event2 |
Number of events (second treatment). |
n2 |
Number of observations (second treatment) |
mean1 |
Estimated mean (first treatment). |
sd1 |
Standard deviation (first treatment). |
mean2 |
Estimated mean (second treatment). |
sd2 |
Standard deviation (second treatment). |
time1 |
Person time at risk (first treatment) |
time2 |
Person time at risk (second treatment) |
data |
An optional data frame containing the study information. |
studlab |
A vector with study labels (optional). |
id1 |
Last character(s) of variable names for additional variables with group specific information for first treatment. |
id2 |
Last character(s) of variable names for additional variables with group specific information for second treatment. |
append |
A logical indicating if data frame provided in argument 'data' should be returned. |
keep.duplicated |
A logical indicating if duplicated rows should be returned (see Details). |
keep.internal |
A logical indicating if variables generated internally should be returned (typically only relevant for data checking). |
This function transforms data given as one pairwise comparison per row to a long arm-based format with one row per treatment arm. The long arm-based format is, for example, the required input format for WinBUGS.
The function can be used to transform data with a binary,
continuous or count outcome. The corresponding meta-analysis
functions are metabin
, metacont
and
metainc
. Accordingly, a meta-analysis object created
with one of these functions can be provided as argument
treat1
. It is also possible to use the longarm function with
an R objected created with pairwise
from R
package netmeta.
Otherwise, arguments treat1
and treat2
are mandatory
to identify the individual treatments and, depending on the
outcome, the following additional arguments are mandatory:
event1, n1, event2, n2 (binary outcome);
n1, mean1, sd1, n2, mean2, sd2 (continuous outcome);
time1, n1, time2, n2 (count outcome).
Argument studlab
must be provided if several pairwise
comparisons come from a single study with more than two treatments.
The following variables will be returned:
studlab | study label |
treat | treatment label |
n | group sample size (count outcome only if provided) |
events | number of events (binary or count outcome) |
nonevents | number of non-events (binary outcome) |
mean | estimated mean (continuous outcome) |
sd | standard deviation (continuous outcome) |
time | person time at risk (count outcome) |
In addition, the data set provided in argument data
will be
returned if argument append = TRUE
(default).
Argument keep.duplicated
can be used to keep duplicated rows
from the data set. Duplicated rows can occur, for example, in a
three-arm study comparing treatments A and B with placebo. In this
situation, the placebo arm will be returned twice in the data set
in long arm-based format if keep.duplicated = TRUE
. By
default, duplicated rows with not be kept in the data set.
A data frame in long arm-based format.
R function to.long
from R package
metafor is called internally.
Guido Schwarzer guido.schwarzer@uniklinik-freiburg.de
metabin
, metacont
,
metainc
, pairwise
# Artificial example with three studies
m <- metabin(1:3, 100:102, 4:6, 200:202, studlab = LETTERS[1:3])
# Transform data to long arm-based format
longarm(m)
# Keep internal variables
longarm(m, keep.internal = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.