"formula's behind them or how to explain results such as Coefficients, Residuals & Multiple R-squared"
Formula: $\hat y = b_{0} + b_{1} * x_{i} $
Coefficients: You have an intercept $b_{0}$ of 2.033 and regression weight $b_{1}$ of 1.784e-04.
To visualize what that means look the following plot:
The intercept is the value on the $y$ axis if $x= 0$ because $\hat y = b_{0} + b_{1} * 0 = \hat y = b_{0}$. Visually speaking that is the point where the regerssion line crosses the $y$ axis.
The $b_{1}$ coefficient tells you how the predicted $\hat y$ values cahnge if $x$ changes by +1. Hence, a positive $b_{1}$ coefficient indicates an increasing and a negative $b_{1}$ coefficient indicates a falling regression line. In your case this means that if the x value is zero the dependend variable y is 2.033. Further, if x increases by 1, the dependent variable y increases by 1.784e-04.
Residuals: You can make predictions with the formula above. You can predict what $y$ someone should have with a $x$ of 12,000, for example. In your case that would be:
$\hat y = 2.033 + 1.784e-04 * 12,000 = 4.1738$
So accordnign to your model someone with a $x$ of 12,000 should have a y of 4.1738. But it may be that there actually are people in your dataset with a $x$ of 12,000 and it is likely that their actual y value is not exactly 4.1738 but let's say 6.1738 and 2.1738. So your prediction made some mistake which is 6.1738 - 4.1738= 2 for one and 2.1738 - 4.1738= -2 for the other person. As you can see the predicted value can be too high or too low and this could give a mean error of 0 (like here: mean of +2 and -2 is 0). This would be misleading because an error of zero implies there is no error. To avoid that we usually use squared the error values, i.e. (6.1738 - 4.1738)$^{2}$ and (2.1738 - 4.1738)$^{2}$. By the way, in OLS the regression coefficients are estimated by "minimizing the sum of the squares of the differences between the observed dependent variable (values of the variable being predicted) in the given dataset and those predicted by the linear function" (see here).
R-square: This value tells you the proportion of the variation of your dependent variable y that was explained with the regression model. In your model the predictor explained 17.58% of the variation in your dependent variable. Keep in mind that you should use an adjusted version of R-squared if you want to compare models with different numbers of predictors.
Note that you write sal$Yrs.since.phd ~ sal$Salary
and if Yrs.since.phd means "years since Phd" it should possibly be the other way around: what you maybe want to do is to predict the salary of a person with the years since the Phd and not to predict the years since Phd with the salary. If so, you can simply switch both variables.
Salary
be a function ofYrs.since.phd
, than the other way around. $\endgroup$