Load R packages

packs <- c("devtools",
           "knitr",
           "MASS",
           "geepack",
           "htmlTable")

lapply(packs, function(x) require(x, character.only = T))

install_github("lisaerein/nicereg")
library(nicereg)

help(nicereg)

options(knitr.kable.NA = '.')

Load survey example dataset from the MASS package

head(survey <- survey)

Example: niceglm function for glm models

Run univariate linear regression and create a table

tab <- niceglm(df = survey,
                 out = "Height",
                 covs = c("Sex", "Age", "Clap"),
                 regtype = "uni",
                 title = "Univariate results",
                 estname = "Estimate",
                 family = "gaussian")

Run multivariable linear regression and create a table

tab <- niceglm(df = survey,
                 out = "Height",
                 covs = c("Sex", "Age", "Clap"),
                 regtype = "multi",
                 title = "Multivariable results",
                 estname = "Estimate",
                 family = "gaussian")

Create a results table from an existing glm model object

survey$lefthanded <- 0
survey$lefthanded[survey$W.Hnd == "Left"] <- 1

fit <- glm(lefthanded ~ Age + Sex + Height + Exer, data = survey, family = "binomial")

tab <- niceglm(fit,
               estname = "aOR",
               overallp = T)

Example: nicegee function for geeglm models

survey$clusterid <- rep(1:5, length = nrow(survey))

tab <- nicegee(df = survey,
                 out = "Height",
                 covs = c("Sex", "Age", "Clap"),
                 regtype = "uni",
                 title = "Uni GEE results",
                 estname = "Estimate",
                 family = "gaussian",
                 id = "clusterid",
                 corstr = "exch")
survey$clusterid <- rep(1:5, length = nrow(survey))

tab <- nicegee(df = survey,
                 out = "Height",
                 covs = c("Sex", "Age", "Clap"),
                 regtype = "multi",
                 title = "Multi GEE results",
                 estname = "Estimate",
                 family = "gaussian",
                 id = "clusterid",
                 corstr = "exch")


lisaerein/nicereg documentation built on July 4, 2020, 9:04 p.m.