| Type: | Package |
| Title: | Create Summary Tables for Statistical Reports |
| Version: | 5.1.1 |
| Date: | 2021-08-01 |
| Author: | Dane R. Van Domelen |
| Maintainer: | Dane R. Van Domelen <vandomed@gmail.com> |
| Description: | Contains functions for creating various types of summary tables, e.g. comparing characteristics across levels of a categorical variable and summarizing fitted generalized linear models, generalized estimating equations, and Cox proportional hazards models. Functions are available to handle data from simple random samples as well as complex surveys. |
| License: | GPL (≥ 3) |
| LazyData: | true |
| Encoding: | UTF-8 |
| Depends: | dplyr, knitr |
| Imports: | kableExtra, MASS, stats, survey (≥ 4.1) |
| RoxygenNote: | 7.1.1 |
| Suggests: | gee, rmarkdown, survival |
| VignetteBuilder: | knitr |
| NeedsCompilation: | no |
| Packaged: | 2021-08-02 00:29:41 UTC; vando |
| Repository: | CRAN |
| Date/Publication: | 2021-08-02 04:30:02 UTC |
Format P-values for Functions in thetab Package
Description
Formats p-values for tables generated by the functions in thetabpackage. Handles rounding and presentation of p-values.
Usage
formatp( p, decimals = c(2, 3), cuts = 0.01, lowerbound = 0.001, leading0 = TRUE, avoid1 = FALSE)Arguments
p | Numeric vector of p-values. |
decimals | Number of decimal places for p-values. If a vector isprovided rather than a single value, number of decimal places will depend onwhat range the p-value lies in. See |
cuts | Cut-point(s) to control number of decimal places used forp-values. For example, by default |
lowerbound | Controls cut-point at which p-values are no longer printedas their value, but rather <lowerbound. For example, by default |
leading0 | If |
avoid1 | If |
Value
Character vector.
Examples
# Generate vector of numeric p-valuesset.seed(123)p <- c(runif(n = 5, min = 0, max = 1), 1, 0, 4e-7, 0.009)# Round to nearest 2 decimals for p in (0.01, 1] and 3 decimals for p < 0.01pvals <- formatp(p = p)# Use 2 decimal places, a lower bound of 0.01, and omit the leading 0pvals <- formatp(p = p, decimals = 2, lowerbound = 0.01, leading0 = FALSE)Print a GLM Summary Table to the RStudio Viewer
Description
You can call this function as you wouldglm or pass apreviously fittedglm object. Either way, the result isa summary table printed to the Viewer.
Usage
glm_v(...)Arguments
... | Arguments to pass to glm. |
Value
kable
Examples
# Fit and viewglm_v(death_1yr ~ Age + Sex + Race, data = tabdata, family = "binomial")# Fit then viewfit <- glm(death_1yr ~ Age + Sex + Race, data = tabdata, family = "binomial")glm_v(fit)# Piping is OMG so cool Hashtag HexStickerzfit %>% glm_v()Create Summary Tables for Statistical Reports
Description
Contains functions for creating various types of summary tables, e.g.comparing characteristics across levels of a categorical variable andsummarizing fitted generalized linear models, generalized estimatingequations, and Cox proportional hazards models. Functions are available tohandle data from simple random samples as well as complex surveys.
Details
| Package: | tab |
| Type: | Package |
| Version: | 5.1.1 |
| Date: | 2021-08-01 |
| License: | GPL-3 |
SeeCRAN documentation forfull list of functions.
Author(s)
Dane R. Van Domelen
vandomed@gmail.com
References
Acknowledgment: This material is based upon work supported by theNational Science Foundation Graduate Research Fellowship under Grant No.DGE-0940903.
Create Summary Table for Fitted Cox Proportional Hazards Model
Description
Creates a table summarizing a GEE fit using thecoxphfunction.
Usage
tabcoxph( fit, columns = c("beta.se", "hr.ci", "p"), var.labels = NULL, factor.compression = 1, sep.char = ", ", decimals = 2, formatp.list = NULL)Arguments
fit | Fitted |
columns | Character vector specifying what columns to include. Choiesfor each element are |
var.labels | Named list specifying labels to use for certain predictors.For example, if |
factor.compression | Integer value from 1 to 5 controlling how muchcompression is applied to factor predictors (higher value = morecompression). If 1, rows are Variable, Level 1 (ref), Level 2, ...; if 2,rows are Variable (ref = Level 1), Level 2, ...; if 3, rows are Level 1(ref), Level 2, ...; if 4, rows are Level 2 (ref = Level 1), ...; if 5, rowsare Level 2, ... |
sep.char | Character string with separator to place between lower andupper bound of confidence intervals. Typically |
decimals | Numeric value specifying number of decimal places for numbersother than p-values. |
formatp.list | List of arguments to pass to |
Value
References
1. Therneau, T. (2015). A Package for Survival Analysis in S. R packageversion 2.38.https://cran.r-project.org/package=survival.
2. Therneau, T.M. and Grambsch, P.M. (2000). Modeling Survival Data:Extending the Cox Model. Springer, New York. ISBN 0-387-98784-3.
Examples
# Cox PH model with age, sex, race, and treatmentlibrary("survival")fit <- coxph( Surv(time = time, event = delta) ~ Age + Sex + Race + Group, data = tabdata)tabcoxph(fit)# Can also use pipingfit %>% tabcoxph()# Same as previous, but with custom labels for Age and Race and factors# displayed in slightly more compressed formatfit %>% tabcoxph( var.labels = list(Age = "Age (years)", Race = "Race/ethnicity"), factor.compression = 2 )# Cox PH model with some higher-order termsfit <- coxph( Surv(time = time, event = delta) ~ poly(Age, 2, raw = TRUE) + Sex + Race + Group + Race*Group, data = tabdata)fit %>% tabcoxph()Sample Dataset fortab Package
Description
Data frame with 15 variables, used to illustrate certain functions.
Source
Simulated data in R
Create Frequency Table
Description
Creates an I-by-J frequency table comparing the distribution ofyacross levels ofx.
Usage
tabfreq( formula = NULL, data = NULL, x = NULL, y = NULL, columns = c("xgroups", "p"), cell = "counts", parenth = "col.percent", sep.char = ", ", test = "chi.fisher", xlevels = NULL, yname = NULL, ylevels = NULL, compress.binary = FALSE, yname.row = TRUE, text.label = NULL, quantiles = NULL, quantile.vals = FALSE, decimals = 1, formatp.list = NULL, n.headings = FALSE, kable = TRUE)Arguments
formula | Formula, e.g. |
data | Data frame containing variables named in |
x | Vector indicating group membership for columns of I-by-J table. |
y | Vector indicating group membership for rows of I-by-J table. |
columns | Character vector specifying what columns to include. Choicesfor each element are |
cell | Character string specifying what statistic to display in cells.Choices are |
parenth | Character string specifying what statistic to display inparentheses. Choices are |
sep.char | Character string with separator to place between lower andupper bound of confidence intervals. Typically |
test | Character string specifying which test for association between |
xlevels | Character vector with labels for the levels of |
yname | Character string with a label for the |
ylevels | Character vector with labels for the levels of |
compress.binary | Logical value for whether to compress binary |
yname.row | Logical value for whether to include a row displaying thename of the |
text.label | Character string with text to put after the |
quantiles | Numeric value. If specified, table compares |
quantile.vals | Logical value for whether labels for |
decimals | Numeric value specifying number of decimal places for numbersother than p-values. |
formatp.list | List of arguments to pass to |
n.headings | Logical value for whether to display group sample sizes inparentheses in column headings. |
kable | Logical value for whether to return a |
Value
Examples
# Compare sex distribution by group(freqtable1 <- tabfreq(Sex ~ Group, data = tabdata))# Same as previous, but showing male row only and % (SE) rather than n (%)(freqtable2 <- tabfreq(Sex ~ Group, data = tabdata, cell = "col.percent", parenth = "se", compress.binary = TRUE))Create Frequency Table (for Complex Survey Data)
Description
Creates an I-by-J frequency table comparing the distribution ofyacross levels ofx.
Usage
tabfreq.svy( formula, design, columns = c("xgroups", "p"), cell = "col.percent", parenth = "se", sep.char = ", ", xlevels = NULL, yname = NULL, ylevels = NULL, compress.binary = FALSE, yname.row = TRUE, text.label = NULL, decimals = 1, svychisq.list = NULL, formatp.list = NULL, n.headings = FALSE, N.headings = FALSE, kable = TRUE)Arguments
formula | Formula, e.g. |
design | Survey design object from |
columns | Character vector specifying what columns to include. Choicesfor each element are |
cell | Character string specifying what statistic to display in cells.Choices are |
parenth | Character string specifying what statistic to display inparentheses. Choices are |
sep.char | Character string with separator to place between lower andupper bound of confidence intervals. Typically |
xlevels | Character vector with labels for the levels of |
yname | Character string with a label for the |
ylevels | Character vector with labels for the levels of |
compress.binary | Logical value for whether to compress binary |
yname.row | Logical value for whether to include a row displaying thename of the |
text.label | Character string with text to put after the |
decimals | Numeric value specifying number of decimal places for numbersother than p-values. |
svychisq.list | List of arguments to pass to |
formatp.list | List of arguments to pass to |
n.headings | Logical value for whether to display unweighted samplesizes in parentheses in column headings. |
N.headings | Logical value for whether to display weighted sample sizesin parentheses in column headings. |
kable | Logical value for whether to return a |
Details
Basicallytabmedians for complex survey data. Relies heavily onthesurvey package.
Value
kable or character matrix.
Examples
# Create survey design objectlibrary("survey")design <- svydesign( data = tabsvydata, ids = ~sdmvpsu, strata = ~sdmvstra, weights = ~wtmec2yr, nest = TRUE)# Compare race distribution by sextabfreq.svy(Race ~ Sex, design)Create Summary Table for Fitted Generalized Estimating Equation Model
Description
Creates a table summarizing a GEE fit using thegeefunction.
Usage
tabgee( fit, data = NULL, columns = NULL, robust = TRUE, var.labels = NULL, factor.compression = 1, sep.char = ", ", decimals = 2, formatp.list = NULL)Arguments
fit | Fitted |
data | Data frame that served as 'data' in function call to |
columns | Character vector specifying what columns to include. Choicesfor each element are |
robust | Logical value for whether to use robust standard errors. |
var.labels | Named list specifying labels to use for certain predictors.For example, if |
factor.compression | Integer value from 1 to 5 controlling how muchcompression is applied to factor predictors (higher value = morecompression). If 1, rows are Variable, Level 1 (ref), Level 2, ...; if 2,rows are Variable (ref = Level 1), Level 2, ...; if 3, rows are Level 1(ref), Level 2, ...; if 4, rows are Level 2 (ref = Level 1), ...; if 5, rowsare Level 2, ... |
sep.char | Character string with separator to place between lower andupper bound of confidence intervals. Typically |
decimals | Numeric value specifying number of decimal places for numbersother than p-values. |
formatp.list | List of arguments to pass to |
Value
Examples
# Load in sample dataset and convert to long formattabdata2 <- reshape(data = tabdata, varying = c("bp.1", "bp.2", "bp.3", "highbp.1", "highbp.2", "highbp.3"), timevar = "bp.visit", direction = "long")tabdata2 <- tabdata2[order(tabdata2$id), ]# Blood pressure at 1, 2, and 3 months vs. age, sex, race, and treatmentlibrary("gee")fit <- gee(bp ~ Age + Sex + Race + Group, id = id, data = tabdata2, corstr = "unstructured")tabgee(fit)# Can also use pipingfit %>% tabgee(data = tabdata2)# Same as previous, but with custom labels for Age and Race and factors# displayed in slightly more compressed formatfit %>% tabgee( data = tabdata2, var.labels = list(Age = "Age (years)", Race = "Race/ethnicity"), factor.compression = 2 )# GEE with some higher-order terms# higher-order termsfit <- gee( highbp ~ poly(Age, 2, raw = TRUE) + Sex + Race + Group + Race*Group, id = id, data = tabdata2, family = "binomial", corstr = "unstructured")fit %>% tabgee(data = tabdata2)Create Summary Table for Fitted Generalized Linear Model
Description
Creates a table summarizing a GLM fit usingglm.
Usage
tabglm( fit, columns = NULL, xvarlabels = NULL, factor.compression = 1, sep.char = ", ", decimals = 2, formatp.list = NULL)Arguments
fit | Fitted |
columns | Character vector specifying what columns to include. Choicesfor each element are |
xvarlabels | Named list specifying labels to use for certain predictors.For example, if |
factor.compression | Integer value from 1 to 5 controlling how muchcompression is applied to factor predictors (higher value = morecompression). If 1, rows are Variable, Level 1 (ref), Level 2, ...; if 2,rows are Variable (ref = Level 1), Level 2, ...; if 3, rows are Level 1(ref), Level 2, ...; if 4, rows are Level 2 (ref = Level 1), ...; if 5, rowsare Level 2, ... |
sep.char | Character string with separator to place between lower andupper bound of confidence intervals. Typically |
decimals | Numeric value specifying number of decimal places for numbersother than p-values. |
formatp.list | List of arguments to pass to |
Value
Examples
# Linear regression: BMI vs. age, sex, race, and treatmentfit <- glm(BMI ~ Age + Sex + Race + Group, data = tabdata)tabglm(fit)# Can also use pipingfit %>% tabglm()# Logistic regression: 1-year mortality vs. age, sex, race, and treatmentfit <- glm( death_1yr ~ Age + Sex + Race + Group, data = tabdata, family = binomial)fit %>% tabglm()# Same as previous, but with custom labels for Age and Race and factors# displayed in slightly more compressed formatfit %>% tabglm( xvarlabels = list(Age = "Age (years)", Race = "Race/ethnicity"), factor.compression = 2 )# Logistic regression model with some higher-order termsfit <- glm( death_1yr ~ poly(Age, 2, raw = TRUE) + Sex + BMI + Sex * BMI, data = tabdata, family = "binomial")fit %>% tabglm()Create Table Comparing Group Means
Description
Creates a table comparing the mean ofy across levels ofx.
Usage
tabmeans( formula = NULL, data = NULL, x = NULL, y = NULL, columns = c("xgroups", "p"), parenth = "sd", sep.char = ", ", variance = "unequal", xlevels = NULL, yname = NULL, text.label = NULL, quantiles = NULL, quantile.vals = FALSE, decimals = NULL, formatp.list = NULL, n.headings = TRUE, kable = TRUE)Arguments
formula | Formula, e.g. |
data | Data frame containing variables named in |
x | Vector of values for the categorical |
y | Vector of values for the continuous |
columns | Character vector specifying what columns to include. Choicesfor each element are |
parenth | Character string specifying what statistic to display inparentheses after the means. Choices are |
sep.char | Character string with separator to place between lower andupper bound of confidence intervals. Typically |
variance | Character string specifying which version of the two-samplet-test to use if |
xlevels | Character vector with labels for the levels of |
yname | Character string with a label for the |
text.label | Character string with text to put after the |
quantiles | Numeric value. If specified, table compares |
quantile.vals | Logical value for whether labels for |
decimals | Numeric value specifying number of decimal places for numbersother than p-values. |
formatp.list | List of arguments to pass to |
n.headings | Logical value for whether to display group sample sizes inparentheses in column headings. |
kable | Logical value for whether to return a |
Details
A t-test is used to compare means ifx has two levels, and a one-wayanalysis of variance is used ifx has more than two levels.Observations with missing values forx and/ory are dropped.
Value
kable or character matrix.
Examples
# Compare mean BMI in control vs. treatment group in sample dataset(meanstable1 <- tabmeans(BMI ~ Group, data = tabdata))# Compare mean baseline systolic BP across tertiles of BMI(meanstable2 <- tabmeans(bp.1 ~ BMI, data = tabdata, quantiles = 3, yname = "Systolic BP"))Create Table Comparing Group Means (for Complex Survey Data)
Description
Creates a table comparing the mean ofy across levels ofx.
Usage
tabmeans.svy( formula, design, columns = c("xgroups", "p"), parenth = "sd", sep.char = ", ", xlevels = NULL, yname = NULL, text.label = NULL, decimals = 1, anova.svyglm.list = NULL, formatp.list = NULL, n.headings = FALSE, N.headings = FALSE, kable = TRUE)Arguments
formula | Formula, e.g. |
design | Survey design object from |
columns | Character vector specifying what columns to include. Choicesfor each element are |
parenth | Character string specifying what statistic to display inparentheses after the means. Choices are |
sep.char | Character string with separator to place between lower andupper bound of confidence intervals. Typically |
xlevels | Character vector with labels for the levels of |
yname | Character string with a label for the |
text.label | Character string with text to put after the |
decimals | Numeric value specifying number of decimal places for numbersother than p-values. |
anova.svyglm.list | List of arguments to pass to |
formatp.list | List of arguments to pass to |
n.headings | Logical value for whether to display group sample sizes inparentheses in column headings. |
N.headings | Logical value for whether to display weighted sample sizesin parentheses in column headings. |
kable | Logical value for whether to return a |
Details
Basicallytabmeans for complex survey data. Relies heavily onthesurvey package.
Value
kable or character matrix.
Examples
# Create survey design objectlibrary("survey")design <- svydesign( data = tabsvydata, ids = ~sdmvpsu, strata = ~sdmvstra, weights = ~wtmec2yr, nest = TRUE)# Compare mean BMI by sex(meanstable <- tabmeans.svy(BMI ~ Sex, design = design))Create Table Comparing Group Medians
Description
Creates a table comparing the median ofy across levels ofx.
Usage
tabmedians( formula = NULL, data = NULL, x = NULL, y = NULL, columns = c("xgroups", "p"), parenth = "iqr", sep.char = ", ", xlevels = NULL, yname = NULL, text.label = NULL, quantiles = NULL, quantile.vals = FALSE, decimals = NULL, formatp.list = NULL, n.headings = TRUE, kable = TRUE)Arguments
formula | Formula, e.g. |
data | Data frame containing variables named in |
x | Vector of values for the categorical |
y | Vector of values for the continuous |
columns | Character vector specifying what columns to include. Choicesfor each element are |
parenth | Character string specifying what values are shown inparentheses after the medians in each cell. Choices are |
sep.char | Character string with separator to place between lower andupper bound of confidence intervals. Typically |
xlevels | Character vector with labels for the levels of |
yname | Character string with a label for the |
text.label | Character string with text to put after the |
quantiles | Numeric value. If specified, table compares |
quantile.vals | Logical value for whether labels for |
decimals | Numeric value specifying number of decimal places for numbersother than p-values. |
formatp.list | List of arguments to pass to |
n.headings | Logical value for whether to display group sample sizes inparentheses in column headings. |
kable | Logical value for whether to return a |
Details
Ifx has 2 levels, a Mann-Whitney U (also known as Wilcoxonrank-sum) test is used to test whether the distribution ofy differsin the two groups; ifx has more than 2 levels, a Kruskal-Wallis testis used to test whether the distribution ofy differs across atleast two of the groups. Observations with missing values forx and/ory are dropped.
Value
Examples
# Compare median BMI in control group vs. treatment group in sample dataset(medtable1 <- tabmedians(BMI ~ Group, data = tabdata))# Compare median baseline systolic BP across tertiles of BMI(medtable2 <- tabmedians(bp.1 ~ BMI, data = tabdata, quantiles = 3, yname = "Systolic BP"))Create Table Comparing Group Medians (for Complex Survey Data)
Description
Creates a table comparing the median ofy across levels ofx.
Usage
tabmedians.svy( formula, design, columns = c("xgroups", "p"), parenth = "iqr", sep.char = ", ", xlevels = NULL, yname = NULL, text.label = NULL, decimals = NULL, svyranktest.list = NULL, formatp.list = NULL, n.headings = FALSE, N.headings = FALSE, kable = TRUE)Arguments
formula | Formula, e.g. |
design | Survey design object from |
columns | Character vector specifying what columns to include. Choicesfor each element are |
parenth | Character string specifying what values are shown inparentheses after the medians in each cell. Choices are |
sep.char | Character string with separator to place between lower andupper bound of confidence intervals. Typically |
xlevels | Character vector with labels for the levels of |
yname | Character string with a label for the |
text.label | Character string with text to put after the |
decimals | Numeric value specifying number of decimal places for numbersother than p-values. |
svyranktest.list | List of arguments to pass to |
formatp.list | List of arguments to pass to |
n.headings | Logical value for whether to display group sample sizes inparentheses in column headings. |
N.headings | Logical value for whether to display weighted sample sizesin parentheses in column headings. |
kable | Logical value for whether to return a |
Details
Basicallytabmedians for complex survey data. Relies heavily onthesurvey package.
Value
kable or character matrix.
Examples
# Create survey design objectlibrary("survey")design <- svydesign( data = tabsvydata, ids = ~sdmvpsu, strata = ~sdmvstra, weights = ~wtmec2yr, nest = TRUE)# Compare median BMI by sex(medtable1 <- tabmedians.svy(BMI ~ Sex, design = design))Create Table Comparing Characteristics Across Levels of a CategoricalVariable
Description
Creates a table comparing multiple characteristics (e.g. median age, meanBMI, and race/ethnicity distribution) across levels ofx.
Usage
tabmulti( formula = NULL, data, xvarname = NULL, yvarnames = NULL, ymeasures = NULL, columns = c("xgroups", "p"), listwise.deletion = FALSE, sep.char = ", ", xlevels = NULL, yvarlabels = NULL, ylevels = NULL, quantiles = NULL, quantile.vals = FALSE, decimals = NULL, formatp.list = NULL, n.headings = FALSE, tabmeans.list = NULL, tabmedians.list = NULL, tabfreq.list = NULL, kable = TRUE)Arguments
formula | Formula, e.g. |
data | Data frame containing variables named in |
xvarname | Character string with name of column variable. Should be oneof |
yvarnames | Character vector with names of row variables. Each elementshould be one of |
ymeasures | Character vector specifying whether each |
columns | Character vector specifying what columns to include. Choicesfor each element are |
listwise.deletion | Logical value for whether observations with missingvalues for any |
sep.char | Character string with separator to place between lower andupper bound of confidence intervals. Typically |
xlevels | Character vector with labels for the levels of |
yvarlabels | Named list specifying labels for certain |
ylevels | Character vector (if only 1 frequency comparison) or list ofcharacter vectors with labels for the levels of each categorical |
quantiles | Numeric value. If specified, function compares |
quantile.vals | Logical value for whether labels for |
decimals | Numeric vector specifying number of decimal places fornumbers other than p-values for each |
formatp.list | List of arguments to pass to |
n.headings | Logical value for whether to display group sample sizes inparentheses in column headings. |
tabmeans.list | List of arguments to pass to |
tabmedians.list | List of arguments to pass to |
tabfreq.list | List of arguments to pass to |
kable | Logical value for whether to return a |
Value
kable or character matrix.
Examples
# Compare age, sex, race, and BMI in control vs. treatment grouptabmulti(Age + Sex + Race + BMI ~ Group, data = tabdata)# Same as previous, but compare medians rather than means for BMItabmulti(Age + Sex + Race + BMI ~ Group, data = tabdata, ymeasures = c("mean", "freq", "freq", "median"))Create Table Comparing Characteristics Across Levels of a CategoricalVariable (for Complex Survey Data)
Description
Creates a table comparing multiple characteristics (e.g. median age, meanBMI, and race/ethnicity distribution) across levels ofx.
Usage
tabmulti.svy( formula = NULL, design, xvarname = NULL, yvarnames = NULL, ymeasures = NULL, columns = c("xgroups", "p"), listwise.deletion = FALSE, sep.char = ", ", xlevels = NULL, yvarlabels = NULL, ylevels = NULL, decimals = NULL, formatp.list = NULL, n.headings = FALSE, N.headings = FALSE, kable = TRUE, tabmeans.svy.list = NULL, tabmedians.svy.list = NULL, tabfreq.svy.list = NULL)Arguments
formula | Formula, e.g. |
design | Survey design object from |
xvarname | Character string with name of column variable. Should be oneof |
yvarnames | Character vector with names of row variables. Each elementshould be one of |
ymeasures | Character vector specifying whether each |
columns | Character vector specifying what columns to include. Choicesfor each element are |
listwise.deletion | Logical value for whether observations with missingvalues for any |
sep.char | Character string with separator to place between lower andupper bound of confidence intervals. Typically |
xlevels | Character vector with labels for the levels of |
yvarlabels | Named list specifying labels for certain |
ylevels | Character vector (if only 1 frequency comparison) or list ofcharacter vectors with labels for the levels of each categorical |
decimals | Numeric vector specifying number of decimal places fornumbers other than p-values for each |
formatp.list | List of arguments to pass to |
n.headings | Logical value for whether to display unweighted samplesizes in parentheses in column headings. |
N.headings | Logical value for whether to display weighted sample sizesin parentheses in column headings. |
kable | Logical value for whether to return a |
tabmeans.svy.list | List of arguments to pass to |
tabmedians.svy.list | List of arguments to pass to |
tabfreq.svy.list | List of arguments to pass to |
Details
Basicallytabmulti for complex survey data. Relies heavily onthesurvey package.
Value
kable or character matrix.
Examples
# Create survey design objectlibrary("survey")design <- svydesign( data = tabsvydata, ids = ~sdmvpsu, strata = ~sdmvstra, weights = ~wtmec2yr, nest = TRUE)# Compare age, race, and BMI by sextabmulti.svy(Age + Race + BMI ~ Sex, design)Create Regression Table from Betas and Standard Errors
Description
Useful for quickly creating a summary table.
Usage
tabreg( betas, ses = NULL, varcov = NULL, columns = c("beta.se", "p"), sep.char = ", ", decimals = NULL, formatp.list = NULL, labels = NULL)Arguments
betas | Numeric vector. |
ses | Numeric vector. |
varcov | Numeric matrix. |
columns | Character vector specifying what columns to include. Choicesare |
sep.char | Character string with separator to place between lower andupper bound of confidence intervals. Typically |
decimals | Numeric value specifying number of decimal places for numbersother than p-values. |
formatp.list | List of arguments to pass to |
labels | Character vector. |
Value
Examples
# Create summary table for mtcars regressionfit <- lm(mpg ~ wt + hp + drat, data = mtcars)tabreg( betas = fit$coef, varcov = vcov(fit), labels = c("Intercept", "Weight", "HP", "Rear axle ratio"))Sample Survey Dataset fortab Package
Description
Data frame with with 9 variables, used to illustrate certain functions. Dataare derived from the National Health and Nutrition Examination Survey, years2003-2004, although the variables 'time' and 'event' are simulated (fake).
Source
https://wwwn.cdc.gov/Nchs/Nhanes/2003-2004/DEMO_C.htm
References
Centers for Disease Control and Prevention (CDC). National Center for HealthStatistics (NCHS). National Health and Nutrition Examination Survey Data.Hyattsville, MD: US Department of Health and Human Services, Centers forDisease Control and Prevention, 2003-2004.https://wwwn.cdc.gov/nchs/nhanes/continuousnhanes/default.aspx?BeginYear=2003.Accessed June 8, 2019.
Output a Table to the RStudio Viewer
Description
Does some basic formatting and then callskable andkable_styling to print table to Viewer.
Usage
toviewer(x)Arguments
x | Character matrix |