ewaff.summarize.relationship: Describe the relationship between two variables.

View source: R/variable-summaries.r

ewaff.summarize.relationshipR Documentation

Describe the relationship between two variables.

Description

Describe the relationship between two variables.

Usage

ewaff.summarize.relationship(vars)

Arguments

vars

A data frame with at least two columns. The first two columns will be compared.

Value

A list whose elements depends on the types of the two variables. In each case, the list contains the following elements:

var1

Name of the first variable, i.e. colnames(vars)[1].

var2

Name of the second variable.

r

Spearman's correlation between the variables. This may be meaningless if one variable is an unordered factor.

r.p

P-value corresponding to the correlation between the variables.

output

The contents of the list formatted to be printed as markdown text.

plot

A plot (ggplot2) visualizing the relationship.

If both variables are factors, then the list will include a frequency table (freq) and a corresponding matrix of p-values (p.values) obtained using Fisher's test to test for enrichment in each cell of the frequency table.

If one variable is a factor and the other numeric, then list will include the F-statistic (F.stat) and p-value (p.value) from one-way analysis of variance. There will also be a data frame (cases) with each row providing statistics from a t-test comparing the numeric variable within and without each level of the factor variable.

If both variables are numeric, then the list will include the F-statistic (F.stat) and p-value (p.value) from the linear model fitting the variables.


perishky/ewaff documentation built on Nov. 10, 2024, 4:53 p.m.