Linear regression with factors in R I'm trying to understand how exactly factors work in R. Let's say I want to run a regression using some sample data in R:
> data(CO2)
> colnames(CO2)
[1] "Plant"     "Type"      "Treatment" "conc"      "uptake"   
> levels(CO2$Type)
[1] "Quebec"      "Mississippi"
> levels(CO2$Treatment)
[1] "nonchilled" "chilled"   
> lm(uptake ~ Type + Treatment, data = CO2)

Call:
lm(formula = uptake ~ Type + Treatment, data = CO2)

Coefficients:
 (Intercept)   TypeMississippi  Treatmentchilled  
       36.97            -12.66             -6.86  

I understand that TypeMississippi and Treatmentchilled are treated as booleans: For each row, the initial uptake is 36.97, and we subtract 12.66 if it's of type Mississippi and 6.86 if it was chilled. I'm having trouble understanding something like this:
 > lm(uptake ~ Type * Treatment, data = CO2)

 Call:
 lm(formula = uptake ~ Type * Treatment, data = CO2)

 Coefficients:
                 (Intercept)                   TypeMississippi  
                      35.333                            -9.381  
            Treatmentchilled  TypeMississippi:Treatmentchilled  
                      -3.581                            -6.557  

What does it mean to multiply two factors together in an lm?
 A: To follow up on John's answer, the formulae in lm don't use arithmetic notation, they're using a compact symbolic notation to describe linear models (specifically Wilkinson-Rogers notation, there's a good short summary here https://www.mathworks.com/help/stats/wilkinson-notation.html).
Basically, including A*B in the model formula means you're fitting A, B, and A:B (the interaction of A and B). If the interaction term is statistically significant, it suggests that the effect of the treatment is different for each of the types.
A: Perhaps looking up 'formula' in help would be of assistance.  You aren't multiplying, you're saying you want the two main effects and their interaction as well.
A: To elaborate on @John's answer: in R's formulas, you have a few operators you can apply to the terms: "+" simply adds them, ":" means that you add a term (or several terms) that refer to their interaction (see below), "*" means both, that is: the "main effects" are added, and the interaction term(s) are added as well.
So what does this interaction mean? Well, in the case of continuous variables, it is indeed a term that is added that is simply the multiple of the two variables. If you'd have height and weight as predictors, and use out ~ height * weight as formula, the linear model will thus contain three 'variables', namely weight, height and their product (it also contains the interaction but that is of less interest here).
Although I suggest otherwise above: this works exactly the same way for categorical variables, but now the 'product' applies to the (set of) dummy variable(s) for each categorical variable. Suppose your height and weight are now categorical, each with three categories (S(mall), M(edium) and L(arge)). Then in linear models, each of these is represented by a set of two dummy variables that are either 0 or 1 (there are other ways of coding, but this is the default in R and the most commonly used). Let's say we use S as the reference category for both, then we have each time two dummies height.M and height.L (and similar for weight).
So now, model out ~ height * weight now contains the 4 dummies + all the products of all dummy-combinations (I'm not explicitly writing the coefficients here, they are implied):
    (intercept) + height.M + height.L + weight.M + weight.L + 
      height.M * weight.M + height.L * weight.M + height.M * 
      weight.L + height.L * weight.L.

In the line above, '*' now again refers to a simple product, but this time of the dummies, so each product itself is also either 1 (when all factors are 1) or 0 (when at least one is not).
In this case the 8 'variables' enable different (mean) outcomes in all combinations of the two variables: the effect of having large weight is now no longer the same for small people (for them the effect is simply formed by the term weight.L) as for large people (here, the effect is weight.L  + height.L * weight.L)
