Programare defensivă în R
Dr. Colin Gillespie
Jumping Rivers
Funcția warning()
warning("You have been warned!")
# Warning message:
# You have been warned!
Similar cu mesajele, avertizările pot fi suprimate cu
suppressWarnings()`Acesta este aproape niciodată un lucru bun de făcut

Fotografie de Austin Chan
Să presupunem că efectuăm o regresie pe
d = data.frame(y = 1:4, x1 = 1:4)
d$x2 = d$x1 + 1
Astfel x2 = x1 + 1
Când ajustăm un model de regresie liniară multiplă
m = lm(y ~ x1 + x2, data = d)
summary(m)
# Some output removed
# Warning message:
# In summary.lm(m) : essentially perfect fit: summary may be unreliable
Programare defensivă în R