This package is originate from table1 to return flextable object. But other functions haven’t been changed, transpose parameters does not work.
An R package for generating tables of descriptive statistics in word.
To install from CRAN:
install.packages("cttab")
To install the latest development version directly from GitHub:
An introduction to the package with examples is provided in the vignette.
For this example, we will use data from the Mayo Clinic trial in primary
biliary cirrhosis (PBC) of the liver found in the survival
package.
require(cttab)
## Loading required package: cttab
require(survival)
## Loading required package: survival
dat <- subset(survival::pbc, !is.na(trt)) # Exclude subjects not randomized
val_lab(dat$trt) <- c("D-penicillamine" = 1, "Placebo" = 2)
val_lab(dat$sex) <- c("Male" = "m", "Female" = "f")
dat$stage <- as.character(dat$stage, levels=1:4)
dat$edema <- factor(dat$edema, levels=c(0, 0.5, 1),
labels =c("No edema",
"Untreated or successfully treated",
"Edema despite diuretic therapy"))
dat$spiders <- as.logical(dat$spiders)
dat$hepato <- as.logical(dat$hepato)
dat$ascites <- as.logical(dat$ascites)
var_lab(dat$age) <- "Age (y)"
var_lab(dat$sex) <- "Sex"
var_lab(dat$stage) <- "Histologic stage of disease"
var_lab(dat$edema) <- "Edema status"
var_lab(dat$spiders) <- "Blood vessel malformations in the skin"
var_lab(dat$hepato) <- "Presence of hepatomegaly or enlarged liver"
var_lab(dat$ascites) <- "Presence of ascites"
var_lab(dat$platelet) <- "Platelet count (× 10<sup>9</sup> per liter)"
var_lab(dat$protime) <- "Standardised blood clotting time"
var_lab(dat$albumin) <- "Serum albumin (g/dL)"
var_lab(dat$alk.phos) <- "Alkaline phosphotase (U/L)"
var_lab(dat$ast) <- "Aspartate aminotransferase (U/mL)"
var_lab(dat$bili) <- "Serum bilirubin (mg/dL)"
var_lab(dat$chol) <- "Serum cholesterol (mg/dL)"
var_lab(dat$copper) <- "Urine copper (μg/day)"
var_lab(dat$trig) <- "Triglycerides (mg/dL)"
out <- tab1(c("age", "sex", "stage", "edema", "spiders", "hepato", "ascites", "platelet", "protime", "albumin", "alk.phos", "ast", "bili", "chol", "copper", "trig"),
group = "trt",
data=dat)
write_table(out)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.