% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/lpcorr.R
\name{lpcor}
\alias{lpcor}
\title{Linear and Partial Correlation Coefficients}
\usage{
lpcor(.data, ..., by = NULL, n = NULL, method = "pearson")
}
\arguments{
\item{.data}{The data to be analyzed. It must be a symmetric correlation
matrix or a data frame, possible with grouped data passed from
\code{\link[dplyr]{group_by}()}.}

\item{...}{Variables to use in the correlation. If \code{...} is null
(Default) then all the numeric variables from \code{.data} are used. It
must be a single variable name or a comma-separated list of unquoted
variables names.}

\item{by}{One variable (factor) to compute the function by. It is a shortcut
to \code{\link[dplyr]{group_by}()}. To compute the statistics by more than
one grouping variable use that function.}

\item{n}{If a correlation matrix is provided, then \code{n} is the number of
objects used to compute the correlation coefficients.}

\item{method}{a character string indicating which correlation coefficient is
to be computed. One of 'pearson' (default), 'kendall', or 'spearman'.}
}
\value{
If \code{.data} is a grouped data passed from
\code{\link[dplyr]{group_by}()} then the results will be returned into a
list-column of data frames, containing:
\itemize{
\item \strong{linear.mat} The matrix of linear correlation.
\item \strong{partial.mat} The matrix of partial correlations.
\item \strong{results} Hypothesis testing for each pairwise comparison.
}
}
\description{
Estimates the linear and partial correlation coefficients using as input a
data frame or a correlation matrix.
}
\examples{
\donttest{
library(metan)
partial1 <- lpcor(iris)

# Alternatively using the pipe operator \%>\%
partial2 <- iris \%>\% lpcor()

# Using a correlation matrix
partial3 <- cor(iris[1:4]) \%>\%
            lpcor(n = nrow(iris))

# Select all numeric variables and compute the partial correlation
# For each level of Species

partial4 <- lpcor(iris, by = Species)
}
}
\author{
Tiago Olivoto \email{tiagoolivoto@gmail.com}
}
