summarize_relationship: Compute statistics summarizing a relationship between...

View source: R/variable_summaries.R

summarize_relationshipR Documentation

Compute statistics summarizing a relationship between variables.

Description

Compute statistics, such as a correlation coefficient, summarizing the relationship between two variables.

Usage

summarize_relationship(data, formula, FUN = cor, ...)

summarise_relationship(data, formula, FUN = cor, ...)

Arguments

data

a data frame containing the variables appearing in formula.

formula

an object of class "formula": a symbolic description identifying the response and the predictor of interest and optionally a grouping variable.

FUN

a function taking at least two arguments, in which the first two arguments are the two variables to be related. Should return a scalar.

...

additional parameters to pass to FUN.

Details

The formula is used to specify the response, the predictor variable and optionally a grouping variable which is specified in the form Response ~ Predictor + Group.

Value

data.frame containing the statistics of interest

Examples

summarize_relationship(mpg ~ hp, data = mtcars, cor)
summarize_relationship(mpg ~ hp, data = mtcars, cor, method = "spearman")


reyesem/IntroAnalysis documentation built on March 29, 2025, 3:29 p.m.