tidy_coef | R Documentation |
This function tidies a table of coefficients. Values can be processed (e.g., by rounding) and row and column names adjusted. A text file can be saved that can be imported into other programmes (e.g., Microsoft Word).
tidy_coef(
coef,
coef_names = rownames(coef),
col_names = c("Coefficient", "Estimate", "SE", "z-value", "p-value")[1:(ncol(coef) +
1)],
f = function(x) prettyGraphics::add_lagging_point_zero(round(x, digits = 3), n = 3),
f_index = 1:ncol(coef),
file = NULL,
quote = FALSE,
sep = ",",
row.names = FALSE,
...
)
coef |
A matrix of model coefficients, usually from |
coef_names |
(optional) A character vector of 'tidy' coefficient names. |
col_names |
(optional) A character vector of 'tidy' column names. The first column name should be the name of the column containing the coefficient names. |
f |
(optional) A function to be applied to specified columns to tidy numeric outputs. |
f_index |
An integer vector of the indices of the columns in |
file |
(optional) A character which defines the name of the file to be saved. This is passed to |
quote |
A logical value which defines whether or not to surround character or factor columns with quotes. This is passed to |
sep |
The field separator string. This is passed to |
row.names |
A logical value which defines whether or not row names are to be saved (or a character vector or the row names to be written). This is passed to |
... |
Other arguments passed to |
The function returns/saves a tidier table of coefficients.
Edward Lavender
n <- 100
x <- runif(n, 0, 1)
y <- rnorm(n, 5*x, 10)
mod <- lm(y ~ x)
tidy_coef(coef(summary(mod)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.