mi_regresion <- function(x,y){ m_x <- mean(x) m_y <- mean(y) n_xy <- sum((x-m_x)*(y-m_y)) d_xx <- sum((x-m_x)^2) b_1 <- n_xy/d_xx b_0 <- m_y-b_1*m_x print(c(b_0, b_1)) } mi_regresion(animacion$Votos, animacion$Puntaje)
## [1] 7.801672e+00 1.476366e-06