#' A simple wrapper on \code{lm()} that takes input in a pipe-friendly order
#' and gives output tidied by \code{broom::tidy()}
#'
#' @param df A dataframe R will pull the variables from to run the regression
#' @param model A model object of class "lm" or a valid formula.
#' @param ... Further arguments to \code{lm()}
#'
#' @return A data frame of model information
#'
#' @examples
#'
#' tidy_lm(mtcars, mpg ~ cyl + am + hp)
#'
#' @importFrom stats lm
#'
#' @export
tidy_lm <- function(df, model, ...){
if (!(class(model) %in% "formula")) {
stop("Please supply a valid formula.")
}
return(broom::tidy(lm(model, df, ...)))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.