R/tabularise.anova.R
tabularise_default.anova.Rd
Create a rich-formatted table from an anova object
# S3 method for class 'anova'
tabularise_default(
data,
header = TRUE,
title = header,
auto.labs = TRUE,
origdata = NULL,
labs = NULL,
lang = getOption("SciViews_lang", "en"),
show.signif.stars = getOption("show.signif.stars", TRUE),
...,
kind = "ft"
)
An anova object
If TRUE
(by default), add a header to the table
If TRUE
, add a title to the table header. Default to the same
value than header, except outside of a chunk where it is FALSE
if a table
caption is detected (tbl-cap
YAML entry).
If TRUE
(by default), use labels (and units) automatically
(from origdata=
)
The original data set used for the ANOVA. By default it is
NULL
. Used to extract labels that are lost in the anova object.
Labels to change the default names in the term
column of the
table. By default it is NULL
and nothing is changed.
The natural language to use. The default value is set with,
e.g., options(SciViews_lang = "fr")
for French.
If TRUE
, add the significance stars to the table.
The default is taken from getOption("show.signif.stars")
.
Additional arguments (not used for now)
The kind of table to produce: "tt" for tinytable, or "ft" for flextable (default).
A flextable object you can print in different form or rearrange with the {flextable} functions.
is <- data.io::read("iris", package = "datasets")
#> Registered S3 method overwritten by 'tsibble':
#> method from
#> as_tibble.grouped_df dplyr
is_lm1 <- lm(data = is, petal_length ~ species)
library(tabularise)
anova(is_lm1) |> tabularise_default()
Analysis of variance
Response: petal_length
Term
Df
Sum of squares
Mean squares
Fobs. value
p value
species
2
437.1
218.551
1180
< 2·10-16
***
Residuals
147
27.2
0.185
0 <= '***' < 0.001 < '**' < 0.01 < '*' < 0.05
# identical
anova(is_lm1) |> tabularise()
Analysis of variance
Response: petal_length
Term
Df
Sum of squares
Mean squares
Fobs. value
p value
species
2
437.1
218.551
1180
< 2·10-16
***
Residuals
147
27.2
0.185
0 <= '***' < 0.001 < '**' < 0.01 < '*' < 0.05
# Use labels
anova(is_lm1) |> tabularise(origdata = is)
Analysis of variance
Response: Length of the petals [cm]
Term
Df
Sum of squares
Mean squares
Fobs. value
p value
Iris species
2
437.1
218.551
1180
< 2·10-16
***
Residuals
147
27.2
0.185
0 <= '***' < 0.001 < '**' < 0.01 < '*' < 0.05
# alternative with anova_() in {modelit} package
anova_(is_lm1) |> tabularise()
Analysis of variance
Response: Length of the petals [cm]
Term
Df
Sum of squares
Mean squares
Fobs. value
p value
Iris species
2
437.1
218.551
1180
< 2·10-16
***
Residuals
147
27.2
0.185
0 <= '***' < 0.001 < '**' < 0.01 < '*' < 0.05
is_lm2 <- lm(data = is, petal_length ~ sepal_length + species)
anova(is_lm1, is_lm2) |> tabularise(origdata = is)
Analysis of variance
Model 1: Length of the petals [cm] ~ Iris species
Model 2: Length of the petals [cm] ~ Length of the sepals [cm] + Iris species
Model
Residuals Df
Residual sum of squares
Df
Sum of squares
Fobs. value
p value
Model 1
147
27.2
Model 2
146
11.7
1
15.6
195
< 2·10-16
***
0 <= '***' < 0.001 < '**' < 0.01 < '*' < 0.05
anova_(is_lm1, is_lm2) |> tabularise()
Analysis of variance
Model 1: Length of the petals [cm] ~ Iris species
Model 2: Length of the petals [cm] ~ sepal_length + Iris species
Model
Residuals Df
Residual sum of squares
Df
Sum of squares
Fobs. value
p value
Model 1
147
27.2
Model 2
146
11.7
1
15.6
195
< 2·10-16
***
0 <= '***' < 0.001 < '**' < 0.01 < '*' < 0.05