[R] lm() notation question

David Winsemius dwinsemius at comcast.net
Sun Nov 29 18:14:32 CET 2009


On Nov 29, 2009, at 11:46 AM, Carl Witthoft wrote:

> Hi,
> A recent thread provided a (working) construct for lm:
>
> lm(as.matrix(freeny[ix]) ~., freeny[-ix])
>
>
> Can someone explain what is meant by the formula in that expression,
> that is,  what does "mymatrix~."  do?

It doesn't say my matrix, it says as.matrix, and that is because  
freeny[iz] is most probably a dataframe.

The lm function is capable of doing manova when given a matrix on the  
LHS of the formula:

http://www.r-project.org/doc/Rnews/Rnews_2007-2.pdf   see page 2 and  
onward of Dalgaard's article.

Toward the end of the Details section of formula help page (easily  
accessed with a click from the lm help page) you will find the  
explanation for the  "~."


> I couldn't find any such example in the lm() or formula() help pages.
>
> thanks
> Carl
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius, MD
Heritage Laboratories
West Hartford, CT




More information about the R-help mailing list