Hinzufügen einer Identitätslinie zu Korrelationsdiagrammen mithilfe des Befehls pairs () in R

Ähnlich wie einvorheriger BeitragMöchte ich den folgenden Code ändern (aus dem Beispiel in der R-Dokumentation zum Befehl pairs ()):

## put (absolute) correlations on the upper panels,
## with size proportional to the correlations.
panel.cor <- function(x, y, digits = 2, prefix = "", cex.cor, ...)
{
    usr <- par("usr"); on.exit(par(usr))
    par(usr = c(0, 1, 0, 1))
    r <- abs(cor(x, y))
    txt <- format(c(r, 0.123456789), digits = digits)[1]
    txt <- paste0(prefix, txt)
    if(missing(cex.cor)) cex.cor <- 0.8/strwidth(txt)
    text(0.5, 0.5, txt, cex = cex.cor * r)
}
pairs(USJudgeRatings, lower.panel = panel.smooth, upper.panel = panel.cor)

Anstelle einer Lösslinie möchte ich für jede Handlung eine Identitätslinie. Das Geheimnis liegt in der $ "panel.smooth" -Funktion, aber ich weiß nicht, wie ich sie ändern soll.

Antworten auf die Frage(2)

Ihre Antwort auf die Frage