traitcombos: Trait combination calculator

Description Usage Arguments Details Value Author(s) References Examples

View source: R/corTools.R

Description

Calculates all simple combinations of traits (addition, subtraction, multiplication, division) and outputs the values

Usage

1
traitcombos(dat, ID)

Arguments

dat

Dataframe name, containing traits in each column. Trait names must be inputted as a header of the dataframe.

ID

Name of the ID column of the dataframe.

Details

ID name must be inputted in quotes, as in "id." Trait combinations are found using the expand.grid function.

Value

Returns a dataframe that includes the original dataframe, but has the trait combinations entered in columns after the original dataframe ends. The combination is specified as a header of the column, and the values are inputted into the columns corresponding to the rows by ID.

Author(s)

Angela Fan

References

Manolio TA, et al. (2009) Finding the missing heritability of complex diseases. Nature 461(747).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# Create a sample dataset
ids <- c(1, 2, 3, 4, 5)
Trait1 <- c(23, 43, 46, 74, 42)
Trait2 <- c(32, 56, 72, 56, 97)
Trait3 <- c(42, 54, 77, 92, 40)
dat <- as.data.frame(cbind(ids, Trait1, Trait2, Trait3))

traitcombos(dat, "ids")
# dat denotes the name of the dataframe
# ids is the name of the ID column
# function returns dataset with additional columns added, where the column names
# are the trait combinations and the column values are the appropriate trait calculations

corTools documentation built on May 2, 2019, 6:39 a.m.