addr2: Add R-Square

View source: R/addr2.R

addr2R Documentation

Add R-Square

Description

addr2 produces an r-squared (r2) expression (r2 = ...) given a vector of observation and prediction.

Usage

addr2(obs, pred, decimal = 2)

Arguments

obs

vector of observation.

pred

vector of prediction.

decimal

displayed decimal places.

Value

An r2 expression for the given vectors of observation and prediction.

Examples

fit = lm(dist ~ speed, data = cars)
plot(cars)
abline(fit, col = 'red')
title(addlmeq(fit, 2), adj = 0.1, line = -1.8, col.main = 'blue', cex.main = 1.1)
title(addr2(cars$dist, predict(fit)), adj = 0.08, line = -2.8, col.main = 'blue', cex.main = 1.1)

jiachengzhao/smot documentation built on Sept. 20, 2022, 6:36 a.m.