This vignette will show a few examples of how to use this package and alter what is output. It will also highlight some restrictions on formats that the user can request.

Default values

The main function used from this package is tablify. This function accepts a series of model output objects as its main arguments, converts the outputs to dataset columns (using the tidy function from the broom package), and then outputs two objects:

library(tabler)

lm1 <- lm(mpg ~ wt, data = mtcars)
lm2 <- lm(mpg ~ wt + cyl, data = mtcars)

tablify(lm1, lm2)

If the user wants to manually manipulate the dataset of regression output:

start_table <- tablify(lm1, lm2)[[1]]

In general, the internal R object output is meant to be intermediary, or used as a preview before exporting the table to share. Exporting is achieved by:

library(WriteXLS)
tablify(lm1, lm2, file = "myresults.csv")
tablify(lm1, lm2, file = "myresults.xls")
tablify(lm1, lm2, file = "myresults.xlsx")

Outputs to xls or xlsx formats requires the WriteXLS package.

Customizing Outputs

The default output can be altered in several ways:

lm3 <- lm(mpg ~ cyl + disp + hp + drat + wt + qsec + vs, data = mtcars)
tablify(lm3)
tablify(lm3, cutoffs = c(0.2, 0.1, 0.05))

# error:
# tablify(lm3, cutoffs = c(0.9, 0.7, 0.5, 0.3, 0.1))

# correct - must supply enugh significance denoters
tablify(lm3, cutoffs = c(0.9, 0.7, 0.5, 0.3, 0.1), 
        stars = c('?', '+', '*', '**', '***'))

tablify(lm1, lm2, lm3, fit = c("r.squared", "adj.r.squared"))

Final note on model types

Since this package relies on broom to tidy model outputs into the columns for tables, it is currently limited to model types handled by broom. For the latest list, see the developer's site. Most frequently-used models should be ready to go, though.

Models of different types (i.e. OLS and ordinal / binary logit) can be combined into one table, so long as the requested outputs are common between all of them. For example, requesting coefficients and their p-values will work, but requesting $R^2$ will fail, as ordinal models do not include this in their outputs.



robertgambrel/tabler documentation built on May 27, 2019, 10:32 a.m.