Skip to content

Commit

Permalink
Export function parse.abbrev.render.code(). Updated README.md.
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminrich committed Apr 25, 2018
1 parent bff3eab commit 740f9fa
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 4 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: table1
Type: Package
Version: 1.0
Date: 2018-04-20
Date: 2018-04-25
Title: Tables of Descriptive Statistics in HTML
Authors@R: person("Benjamin", "Rich", role=c("aut", "cre"), email="[email protected]")
Description: Create HTML tables of descriptive statistics, as one would expect
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export("units<-")
export(has.label)
export(has.units)
export(label)
export(parse.abbrev.render.code)
export(render.categorical.default)
export(render.continuous.default)
export(render.default)
Expand Down
1 change: 1 addition & 0 deletions R/table1.R
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ render.default <- function(x, name, missing=any(is.na(x)), transpose=F,
#' }
#'
#' @keywords utilities
#' @export
parse.abbrev.render.code <-
function(code, ...) {
codestr <- code
Expand Down
61 changes: 59 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,69 @@
# table1

[![Travis-CI Build Status](https://travis-ci.org/benjaminrich/table1.svg?branch=master)](https://travis-ci.org/benjaminrich/table1)

An R package for generating tables of descriptive statistics in HTML.

To install directly from GitHub:
## Installation

To install from CRAN:

``` r
install.packages("table1")
```

To install the latest development version directly from GitHub:

``` r
require(devtools)
devtools::install_github("benjaminrich/table1")
```

To see some examples, have a look at the [vignette](https://benjaminrich.github.io/table1/vignettes/table1-examples.html).
## Getting Started

An introduction to the package with examples is provided in the [vignette](https://benjaminrich.github.io/table1/vignettes/table1-examples.html).

## Example

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.

``` r
require(table1)
require(survival)

dat <- subset(survival::pbc, !is.na(trt)) # Exclude subjects not randomized

dat$trt <- factor(dat$trt, levels=1:2, labels=c("D-penicillamine", "Placebo"))
dat$sex <- factor(dat$sex, levels=c("m", "f"), labels=c("Male", "Female"))
dat$stage <- factor(dat$stage, levels=1:4, labels=paste("Stage", 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)

label(dat$age) <- "Age (y)"
label(dat$sex) <- "Sex"
label(dat$stage) <- "Histologic stage of disease"
label(dat$edema) <- "Edema status"
label(dat$spiders) <- "Blood vessel malformations in the skin"
label(dat$hepato) <- "Presence of hepatomegaly or enlarged liver"
label(dat$ascites) <- "Presence of ascites"
label(dat$platelet) <- "Platelet count (&times; 10<sup>9</sup> per liter)"
label(dat$protime) <- "Standardised blood clotting time"
label(dat$albumin) <- "Serum albumin (g/dL)"
label(dat$alk.phos) <- "Alkaline phosphotase (U/L)"
label(dat$ast) <- "Aspartate aminotransferase (U/mL)"
label(dat$bili) <- "Serum bilirubin (mg/dL)"
label(dat$chol) <- "Serum cholesterol (mg/dL)"
label(dat$copper) <- "Urine copper (&mu;g/day)"
label(dat$trig) <- "Triglycerides (mg/dL)"

table1(~ age + sex + stage + edema + spiders + hepato + ascites +
platelet + protime + albumin + alk.phos + ast + bili + chol +
copper + trig | trt, data=dat)
```

![Example result: table of descriptive statistics from pbc data](tools/readme/table1-example-pbc.png)
2 changes: 1 addition & 1 deletion cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Test environments

* Local Windows 8.1, R 3.4.4 (x86_64-w64-mingw32)
* Local Windows 8.1, R 3.5.0 (x86_64-w64-mingw32)
* Linux on travis-ci (release and devel)
* win-builder (release and devel)

Expand Down
Binary file added tools/readme/table1-example-pbc.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 740f9fa

Please sign in to comment.