knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
The goal of ezlm is to fit a simple linear regression model, outputting easy-to-read results rounded to user's preferred decimal place. A wrapper for lm().
The ezlm package is not yet available from CRAN. Please download it from this repository using the following R command:
devtools::install_github("deansn/ezlm")
mtcars
As a basic demonstration of the ezlm()
function, begin by calling the function and inputting the appropriate variables (as described in the documentation above).
Let's say we're interested in the effect of fuel economy on horsepower, and we want to see our results to three decimal places:
library(ezlm) ezlm(mtcars, mtcars$mpg, mtcars$hp, 3)
USArrests
While this function was designed primarily for linear regressions within the mtcars
dataset, it should work with other datasets, such as USArrests
. In this example, let's look at the influence of the urban population proportion on the number of assault charges.
ezlm(USArrests, USArrests$UrbanPop, USArrests$Assault, 2)
To force my function to throw one of my custom error messages, we can try to replace one of the numerical parameters with a non-accepted input class:
ezlm(mtcars, as.factor(mtcars$mpg), mtcars$hp, 3)
As expected, the function throws the custom error message when the IV is defined as a factor variable.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.