treats: Abbreviate treatment names

View source: R/treats.R

treatsR Documentation

Abbreviate treatment names

Description

Auxiliary functions to create uniquely abbreviated treatment names.

Usage

treats(x, nchar.trts = 8, row = TRUE)

comps(x, trts, sep.trts, nchar.trts = 8, row = TRUE)

Arguments

x

A vector with treatment or comparison names or a matrix with treatment or comparison names as row and / or column names.

nchar.trts

A numeric defining the minimum number of characters used to create unique treatment names.

row

A logical indicating whether row or column names should be used (only considered if argument x is a matrix).

trts

A character vector with treatment names.

sep.trts

A character used in comparison names as separator between treatment labels.

Details

These auxiliary functions can be used to create uniquely abbreviated treatment names (and are used internally in several R functions for this purpose).

In order to construct uniquely abbreviated treatment names, treats uses substring to extract the first nchar.trts characters. If these abbreviated treatment names are not unique, abbreviate with argument minlength = nchar.trts is used.

In order to construct comparisons with uniquely abbreviated treatment names, comps calls treats internally.

Author(s)

Guido Schwarzer guido.schwarzer@uniklinik-freiburg.de

See Also

netmeta, print.netmeta, print.summary.netmeta

Examples

data(smokingcessation)

# Transform data from arm-based format to contrast-based format
#
p1 <- pairwise(list(treat1, treat2, treat3),
  event = list(event1, event2, event3), n = list(n1, n2, n3),
  data = smokingcessation, sm = "OR")

# Conduct random effects network meta-analysis and show data frame
#
net1 <- netmeta(p1, common = FALSE)

# Full treatment names
#
net1$trts

# Treatment names with maximal four characters
#
treats(net1$trts, nchar.trts = 4)

## Not run: 
data(Senn2013)
#
net2 <- netmeta(TE, seTE, treat1.long, treat2.long, studlab,
  data = Senn2013)

# Full treatment names
#
net2$trts

# Treatment names with four characters
#
treats(net2$trts, nchar.trts = 4)

# With two characters
#
treats(net2$trts, nchar.trts = 2)

# With one character (if possible)
#
treats(net2$trts, nchar.trts = 1)

# Full comparison names
#
net2$comparisons

# Abbreviated comparison names
#
with(net2, comps(comparisons, trts, sep.trts, nchar = 4))

## End(Not run)


netmeta documentation built on June 23, 2024, 9:06 a.m.