format.ggeffects | R Documentation |
A generic print-method for ggeffects
-objects.
## S3 method for class 'ggeffects'
format(
x,
variable_labels = FALSE,
value_labels = FALSE,
group_name = FALSE,
row_header_separator = ", ",
digits = 2,
collapse_ci = FALSE,
collapse_tables = FALSE,
n,
...
)
## S3 method for class 'ggcomparisons'
format(x, collapse_ci = FALSE, collapse_p = FALSE, combine_levels = FALSE, ...)
## S3 method for class 'ggeffects'
print(x, group_name = TRUE, digits = 2, verbose = TRUE, ...)
## S3 method for class 'ggeffects'
print_md(x, group_name = TRUE, digits = 2, ...)
## S3 method for class 'ggeffects'
print_html(
x,
group_name = TRUE,
digits = 2,
theme = NULL,
engine = c("tt", "gt"),
...
)
## S3 method for class 'ggcomparisons'
print(x, collapse_tables = FALSE, ...)
## S3 method for class 'ggcomparisons'
print_html(
x,
collapse_ci = FALSE,
collapse_p = FALSE,
theme = NULL,
engine = c("tt", "gt"),
...
)
## S3 method for class 'ggcomparisons'
print_md(x, collapse_ci = FALSE, collapse_p = FALSE, theme = NULL, ...)
x |
An object of class |
variable_labels |
Logical, if |
value_labels |
Logical, if |
group_name |
Logical, if |
row_header_separator |
Character, separator between the different subgroups in the table output. |
digits |
Number of digits to print. |
collapse_ci |
Logical, if |
collapse_tables |
Logical, if |
n |
Number of rows to print per subgroup. If |
... |
Further arguments passed down to |
collapse_p |
Logical, if |
combine_levels |
Logical, if |
verbose |
Toggle messages. |
theme |
The theme to apply to the table. One of |
engine |
The engine to use for printing. One of |
format()
return a formatted data frame, print()
prints a
formatted data frame to the console. print_html()
returns a tinytable
object by default (unless changed with engine = "gt"
), which is printed as
HTML, markdown or LaTeX table (depending on the context from which
print_html()
is called, see tinytable::tt()
for details).
The verbose
argument can be used to display or silence messages and
warnings. Furthermore, options()
can be used to set defaults for the
print()
and print_html()
method. The following options are available,
which can simply be run in the console:
ggeffects_ci_brackets
: Define a character vector of length two, indicating
the opening and closing parentheses that encompass the confidence intervals
values, e.g. options(ggeffects_ci_brackets = c("[", "]"))
.
ggeffects_collapse_ci
: Logical, if TRUE
, the columns with predicted
values (or contrasts) and confidence intervals are collapsed into one
column, e.g. options(ggeffects_collapse_ci = TRUE)
.
ggeffects_collapse_p
: Logical, if TRUE
, the columns with predicted
values (or contrasts) and p-values are collapsed into one column, e.g.
options(ggeffects_collapse_p = TRUE)
. Note that p-values are replaced
by asterisk-symbols (stars) or empty strings when ggeffects_collapse_p = TRUE
,
depending on the significance level.
ggeffects_collapse_tables
: Logical, if TRUE
, multiple tables for
subgroups are combined into one table. Only works when there is more than
one focal term, e.g. options(ggeffects_collapse_tables = TRUE)
.
ggeffects_output_format
: String, either "text"
, "markdown"
or "html"
.
Defines the default output format from predict_response()
. If "html"
, a
formatted HTML table is created and printed to the view pane. "markdown"
creates a markdown-formatted table inside Rmarkdown documents, and prints
a text-format table to the console when used interactively. If "text"
or
NULL
, a formatted table is printed to the console, e.g.
options(ggeffects_output_format = "html")
.
ggeffects_html_engine
: String, either "tt"
or "gt"
. Defines the default
engine to use for printing HTML tables. If "tt"
, the tinytable package
is used, if "gt"
, the gt package is used, e.g.
options(ggeffects_html_engine = "gt")
.
Use options(<option_name> = NULL)
to remove the option.
data(efc, package = "ggeffects")
fit <- lm(barthtot ~ c12hour + e42dep, data = efc)
# default print
predict_response(fit, "e42dep")
# surround CI values with parentheses
print(predict_response(fit, "e42dep"), ci_brackets = c("(", ")"))
# you can also use `options(ggeffects_ci_brackets = c("[", "]"))`
# to set this globally
# collapse CI columns into column with predicted values
print(predict_response(fit, "e42dep"), collapse_ci = TRUE)
# include value labels
print(predict_response(fit, "e42dep"), value_labels = TRUE)
# include variable labels in column headers
print(predict_response(fit, "e42dep"), variable_labels = TRUE)
# include value labels and variable labels
print(predict_response(fit, "e42dep"), variable_labels = TRUE, value_labels = TRUE)
data(iris)
m <- lm(Sepal.Length ~ Species * Petal.Length, data = iris)
# default print with subgroups
predict_response(m, c("Petal.Length", "Species"))
# omit name of grouping variable in subgroup table headers
print(predict_response(m, c("Petal.Length", "Species")), group_name = FALSE)
# collapse tables into one
print(predict_response(m, c("Petal.Length", "Species")), collapse_tables = TRUE, n = 3)
# increase number of digits
print(predict_response(fit, "e42dep"), digits = 5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.