R-CMD-check Codecov test coverage CRAN status r-universe status License: MIT Lifecycle: experimental

knitr::opts_chunk$set(collapse = TRUE, comment = "#>",
  fig.path = "man/figures/README-", out.width = "80%")
library(modelit)
library(tabularise)
library(chart)

The {modelit} package adds the statistical models to the SciViews::R dialect. It uses both the fun$type(data = ...., formula) approach and the enhanced formula allowing to specify arguments with %arg=% directly inside the formula. It also takes the variable labels into account in the outputs.

The {modelit} package provides methods (lm, glm; nls objects) for the chart() function in the {chart} package and the tabularise() function in the {tabularise} package.

Installation

{modelit} is not available from CRAN yet. You should install it from the SciViews R-Universe. {chart} is an alternate formula interface to {ggplot2}. {tabularise} produces publication-ready (rich-formatted) tabular output. The {equatags} and {equatiomatic} packages are optional, but they are useful to display equations, both inline in R Markdown/Quarto documents and in {tabularise} tables. {data.io} is useful too because it manages labels and units that {chart} uses. To install these six packages and their dependencies, run the following command in R:

install.packages(c('modelit', 'chart', 'tabularise', 'equatags', 'equatiomatic', 'data.io'),
  repos = c('https://sciviews.r-universe.dev', 'https://cloud.r-project.org'))

You can also install the latest development version of {modelit}. Make sure you have the {remotes} R package installed:

# install.packages("remotes")
remotes::install_github("SciViews/modelit")

Short example

library(modelit)
library(tabularise)
library(chart)

The trees datasets present diameter, height and volume for Black Cherry Trees (Prunus serotina, Ehrh., 1788)

data('trees', package = 'datasets')

We perform a polynomial regression of the volume of timber as a function of the girth of the trees.

trees_lm <- lm(Volume ~ Girth + I(Girth^2), data = trees)
summary(trees_lm)

Here is the summary of the model, using tabularise():

summary(trees_lm) |> tabularise()

The model can be viewed using chart():

chart(trees_lm)

Residual analysis plots can also be carried out with chart().

chart$residuals(trees_lm)

For further examples, please, refer to the help pages at https://www.sciviews.org/modelit/.

Code of Conduct

Please note that the {modelit} package is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.



SciViews/modelit documentation built on Nov. 24, 2024, 10:23 a.m.