omixerCorr: Correlation Tests

Description Usage Arguments Details Value Examples

View source: R/omixerCorr.R

Description

This function uses appropriate tests of correlation between two variables and stores the estimate and p-value in a list.

Usage

1
omixerCorr(x, y)

Arguments

x

Randomization variable (e.g. age)

y

Technical covariate (e.g. plate number)

Details

For two categorical variables, the Cramer's V estimate is stored alongside chi-square p-value. For all other combinations of variables, Pearson's correlation coefficient and p-value are stored.

Please note: variables will be converted to numeric class within this function.

Value

List of correlation estimate and p-value

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
library(tibble)
library(forcats)
library(stringr)

sampleList <- tibble(sampleId=str_pad(1:48, 4, pad="0"),
sex=as_factor(sample(c("m", "f"), 48, replace=TRUE)), 
age=round(rnorm(48, mean=30, sd=8), 0), 
smoke=as_factor(sample(c("yes", "ex", "never"), 48, replace=TRUE)),
date=sample(seq(as.Date('2008/01/01'), as.Date('2016/01/01'), 
    by="day"), 48))
                
omixerCorr(sampleList$age, sampleList$sex)

Omixer documentation built on Feb. 4, 2021, 2:01 a.m.