View source: R/variable-summaries.r
ewaff.summarize.relationship | R Documentation |
Describe the relationship between two variables.
ewaff.summarize.relationship(vars)
vars |
A data frame with at least two columns. The first two columns will be compared. |
A list whose elements depends on the types of the two variables. In each case, the list contains the following elements:
Name of the first variable, i.e. colnames(vars)[1].
Name of the second variable.
Spearman's correlation between the variables. This may be meaningless if one variable is an unordered factor.
P-value corresponding to the correlation between the variables.
The contents of the list formatted to be printed as markdown text.
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.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.