R/accuracy_metrics.R
R_squared.Rd
The coefficient of determination, often called R squared, is the proportion of data variance explained by the predictions.
R_squared(y, y_hat, na.rm = FALSE)
Vector of observations or ground-truths.
Vector of predictions.
A logical value indicating whether NA values should be stripped before the computation proceeds.
NA
The R squared of the predictions y_hat for y.
y_hat
y
R_squared(c(2.3, 4.2, 1.8), c(2.2, 4.6, 1.7)) #> [1] 0.9438669