Learn R Programming

valueprhr (version 0.1.0)

compute_r2: Compute In-Sample R-squared

Description

Calculates the coefficient of determination (R-squared) for predictions.

Usage

compute_r2(actual, predicted)

Value

A single numeric R-squared value, or NA if not computable.

Arguments

actual

Numeric vector of actual values.

predicted

Numeric vector of predicted values.

Examples

Run this code
actual <- c(1, 2, 3, 4, 5)
predicted <- c(1.1, 1.9, 3.1, 4.0, 4.9)
compute_r2(actual, predicted)

Run the code above in your browser using DataLab