Are the following two equivalent, i.e. do they define the same function?
function(df) {lm(mpg ~ wt, data=df)}
and
function(df) lm(mpg ~ wt, data=df)
In particular, I am confused about why it is possible to write functions without curly brackets in R.
Are curly brackets only necessary for defining a function when the function definition extends over more than one line?
(Perhaps something about how R and Python technically support the semi-colons from C but it's considered bad practice to use them?)
This would seem to explain perhaps why people do not generally use curly brackets when defining anonymous functions, because anonymous functions are usually short and thus can fit on one line, so curly brackets are not necessary.
But would it be possible to pass anonymous functions whose definitions are longer than one line (obviously this would probably be bad practice, but that's not my point)?
If it is possible, does that require curly brackets?