Skip to content
Snippets Groups Projects
compute_rsquare.Rd 1 KiB
Newer Older
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/rsquare.R
\name{compute_rsquare}
\alias{compute_rsquare}
\title{Compute R-squared values for linear regression on grouped data}
\usage{
compute_rsquare(data, grouping_by = c("from", "description"))
}
\arguments{
\item{data}{A data frame containing the variables 'actual' and 'estimate' for regression.}

\item{grouping_by}{A character vector specifying the grouping variables for regression.}
}
\value{
A data frame with columns 'from', 'term', and 'R2' representing the grouping variables
and the corresponding R-squared values.
}
\description{
This function takes a data frame, performs linear regression on specified grouping variables,
and computes R-squared values for each group.
}
\examples{
data <- data.frame(from = c("A", "A", "A", "A"),
                   term = c("X", "Y", "X", "Y"),
                   actual = c(1, 2, 3, 4),
                   estimate = c(1.5, 2.5, 3.5, 4.5))
compute_rsquare(data, grouping_by = c("from", "term"))

}