# R: anova(lm): What is the Sum Sq when we have two inputs

What is the formula to calculate the Sum sq column for the inputs?

Answers to some other questions state, that it should be

$$RSS = \sum (\hat Y_i -\bar Y)^2$$,

yet this is false, it only gives the sum of those values for all input.

In this example anova picture, I want to know the formula to calculate 162392 and 3048.