knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
The linreg-package implements the functionality of a linear regression.
To fit a linear model, a new linreg-object has to be created, with the dataset and a respective formula for the model as inputs. An example could look like this:
# load the package library(linearregressionlab) # create new linreg object data(iris) mod_object <- linreg(Petal.Length~Species, data = iris) mod_object
In the following code examples, the major methods for the linear regression can be found:
# show coefficients mod_object$coef() # show residuals mod_object$resid()[1:10] # show predictions mod_object$pred()[1:10] # get summary of the regression mod_object$summary()
# plot overview of regression mod_object$plot()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.