Why is my lm() model unaltered by addition of a random effect? I have a dataset with repeated measures (each plantID is tested at 4 different ppm of CO2 - image below). I have tried analyzing the data with and without a random effect of plantID:
lm(CER ~ ppm, data = dataset) and
lm(CER ~ ppm + (1|plantID), data=dataset)
The output is identical in both cases. This even happens when I make up a "toy" example with a strong effect of plant ID, where I would really expect different results with and without the random effect.
Adding the random effect causes a "Coefficient not defined because of singularities" message. However, according to the cor() function, my two independent variables (plantID and ppm) are NOT correlated with each other, which is often given as the explanation for this error message. Is the structure of the data incorrect in some way..? Should I simply refrain from adding a random effect of plant ID to this model?


lm is a function for estimating fixed-effects regression only, it does not handle random effects. For random effects, you need to use libraries such as nlme or lme4.
What your code does is it translates | to logical or operation, because R allows for such operations in the formula. In mixed-effects models (when using the packages above), the operation is overloaded and has a special meaning. To convince yourself, look at the result of the code below:
> model.matrix(lm(mpg ~ hp + (1|carb) + (0|am), data=mtcars))
                    (Intercept)  hp 1 | carbTRUE 0 | amTRUE
Mazda RX4                     1 110            1          1
Mazda RX4 Wag                 1 110            1          1
Datsun 710                    1  93            1          1
Hornet 4 Drive                1 110            1          0
Hornet Sportabout             1 175            1          0
Valiant                       1 105            1          0
Duster 360                    1 245            1          0
Merc 240D                     1  62            1          0
Merc 230                      1  95            1          0
Merc 280                      1 123            1          0
...

As you can see, (1|carb) produced a column of ones as 1 OR something leads to all values being true (ones), (0|am) leads to 0 OR 1-or-0 leads to ones, and zeros depending on the second column, because the left-hand side is false (zero). You can also see a hint in the column names 1 | carbTRUE.
It is a consequence of the fact that R allows for great flexibility when writing the code, here it backfires leading to unexpected behavior for someone familiar with mixed-effects formulas.
The constant column would not change anything about linear regression results.
