R: Automate Extraction of Linear Regression Equation from lm [duplicate]
问题 This question already has answers here : Extract Formula From lm with Coefficients (R) (3 answers) Closed 4 years ago . Does anyone know of an existing function to extract the full linear equation from a lm object? Suppose I have: lm1 = lm(y~x1+x2...xn, data=df) For this course in regression I'm taking, the professor repeatedly wants the resulting regression equation in the form: e(y) = b1 +b2x1 [...] bnx(n-1). Currently, I am doing something like this: (paste("y=", coef(lm1)[1], '+', coef