demtables
is a package for making simple demographic tables.
Installation is simplest through devtools::install_github
. The package depends on dplyr
, tidyr
, htmlTable
, and formula.tools
.
devtools::install_github('sean-cho/demtables')
The main workhorse of the demtables
package is the function dem_table
which takes a data.frame
and expression
as an argument.
library(demtables) library(dplyr) library(survival) data(ovarian) ovarian %>% mutate(resid.ds = ifelse(resid.ds == 1,'no','yes'), rx = factor(rx)) %>% dem_table(rx ~ .)
Alternatively, you could select specific variables.
ovarian %>% mutate(resid.ds = ifelse(resid.ds == 1,'no','yes'), rx = factor(rx)) %>% dem_table(rx ~ age + resid.ds)
The make_dem_table
and view_dem_table
functions create HTML tables that will be displayed in the Viewer if you use RStudio. make_dem_table
can be used directly in HTML Markdowns.
ovarian %>% mutate(resid.ds = ifelse(resid.ds == 1,'no','yes'), rx = factor(rx)) %>% make_dem_table(rx ~ age + resid.ds, 'Ovarian data')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.