2

I am a C# developer, new to R, trying to understand the code line

fit <- lm(quality ~ .,wine)

I get that this creates a list called fit and that

quality ~ .

must somehow instantiate an object of class "formula" for use within the lm function.

from typing

help("~") 

into the R Studio Console, I see that

Tilde is used to separate the left- and right-hand sides in a model formula.
Usage y ~ model
Arguments y, model symbolic expressions.
Details The left-hand side is optional, and one-sided formulae are used in some contexts.

A formula has mode call. It can be subsetted by [[: the components are ~, the left-hand side (if present) and the right-hand side in that order.

But I am not told what the left and right sides in a model formula are.

What does the following mean?

quality ~ .

What is meant by

the left and right hand sides

of a model formula?

Kirsten
  • 15,730
  • 41
  • 179
  • 318

1 Answers1

1

As this is concerned with formula, we can check the documentation of ?formula

There are two special interpretations of . in a formula. The usual one is in the context of a data argument of model fitting functions and means ‘all columns not otherwise in the formula’: see terms.formula. In the context of update.formula, only, it means ‘what was previously in this part of the formula’.

enter image description here

akrun
  • 874,273
  • 37
  • 540
  • 662