R tips 1: playing with polynomials

Polynomial equation as annotation
Polynomial equation as annotation to a ggplot.

I have collected some code snippets I used recently for working with polynomials. The idea of writing this page came from a question I was asked a few days ago by Titta Kotilainen. I should emphasize that the page linked below concerns only polynomials, and excludes all other linear models that can be fit with lm(). Even models that are polynomials but formulated not as a regular polynomial equation (e.g. x ~ I(x^2) + x instead of the expected x + I(x^2) will quietly fail! In contrast, use of poly() as in y ~ poly(x, 2) is fine.

I used Rmarkdown in RStudio to generate a page with knitted examples, if interested the source file is also available.

 

Leave a Reply

Your email address will not be published. Required fields are marked *