From 1b8c50158a0b9ff11932f1db84837407d7f3627b Mon Sep 17 00:00:00 2001 From: kaz-yos Date: Fri, 14 Feb 2014 20:10:49 -0500 Subject: [PATCH] better example table for README on github --- README.md | 79 ++++++++++++++++++++++++------------------------------- 1 file changed, 34 insertions(+), 45 deletions(-) diff --git a/README.md b/README.md index 3275040..125d137 100644 --- a/README.md +++ b/README.md @@ -9,61 +9,50 @@ This package creates "Table 1", i.e., description of baseline patient characteri Examples ------------------------------------------------------------------------------- +The tableone package creates tables like the one below. In this table, continuous and categorical variables are ordered in an arbitrary order. The p-valeus are from exact tests for pre-specified variables. For nonnormal variables, it shows median and IQR instead of mean and SD, and test is via nonparametric tests. + See also the demonstration here: http://rpubs.com/kaz_yos/tableone-demo-e ``` -## Make categorical variables factors -> varsToFactor <- c("status","trt","ascites","hepato","spiders","edema","stage") -> pbc[varsToFactor] <- lapply(pbc[varsToFactor], factor) -## Create a variable list. Use dput(names(pbc)) -> vars <- c("time","status","age","sex","ascites","hepato", -+ "spiders","edema","bili","chol","albumin", -+ "copper","alk.phos","ast","trig","platelet", -+ "protime","stage") -## Create Table 1 stratified by trt (omit strata argument for overall table) > tableOne <- CreateTableOne(vars = vars, strata = "trt", data = pbc) -## Just typing the object name will invoke the print.TableOne method -## Tests are by oneway.test/t.test for continuous, chisq.test for categorical -> tableOne - Stratified by trt - 1 2 p test - n 158 154 - time (mean (sd)) 2015.62 (1094.12) 1996.86 (1155.93) 0.883 - status (%) 0.894 - 0 83 (52.5) 85 (55.2) - 1 10 ( 6.3) 9 ( 5.8) - 2 65 (41.1) 60 (39.0) - age (mean (sd)) 51.42 (11.01) 48.58 (9.96) 0.018 - sex = f (%) 137 (86.7) 139 (90.3) 0.421 - ascites = 1 (%) 14 (8.9) 10 (6.5) 0.567 - hepato = 1 (%) 73 (46.2) 87 (56.5) 0.088 - spiders = 1 (%) 45 (28.5) 45 (29.2) 0.985 - edema (%) 0.877 - 0 132 (83.5) 131 (85.1) - 0.5 16 (10.1) 13 ( 8.4) - 1 10 ( 6.3) 10 ( 6.5) - bili (mean (sd)) 2.87 (3.63) 3.65 (5.28) 0.131 - chol (mean (sd)) 365.01 (209.54) 373.88 (252.48) 0.748 - albumin (mean (sd)) 3.52 (0.44) 3.52 (0.40) 0.874 - copper (mean (sd)) 97.64 (90.59) 97.65 (80.49) 0.999 - alk.phos (mean (sd)) 2021.30 (2183.44) 1943.01 (2101.69) 0.747 - ast (mean (sd)) 120.21 (54.52) 124.97 (58.93) 0.460 - trig (mean (sd)) 124.14 (71.54) 125.25 (58.52) 0.886 - platelet (mean (sd)) 258.75 (100.32) 265.20 (90.73) 0.555 - protime (mean (sd)) 10.65 (0.85) 10.80 (1.14) 0.197 - stage (%) 0.201 - 1 12 ( 7.6) 4 ( 2.6) - 2 35 (22.2) 32 (20.8) - 3 56 (35.4) 64 (41.6) - 4 55 (34.8) 54 (35.1) +> print(tableOne, nonnormal = c("bili","chol","copper","alk.phos","trig"), exact = c("status","stage")) + Stratified by trt + 1 2 p test + n 158 154 + time (mean (sd)) 2015.62 (1094.12) 1996.86 (1155.93) 0.883 + status (%) 0.884 exact + 0 83 (52.5) 85 (55.2) + 1 10 ( 6.3) 9 ( 5.8) + 2 65 (41.1) 60 (39.0) + age (mean (sd)) 51.42 (11.01) 48.58 (9.96) 0.018 + sex = f (%) 137 (86.7) 139 (90.3) 0.421 + ascites = 1 (%) 14 (8.9) 10 (6.5) 0.567 + hepato = 1 (%) 73 (46.2) 87 (56.5) 0.088 + spiders = 1 (%) 45 (28.5) 45 (29.2) 0.985 + edema (%) 0.877 + 0 132 (83.5) 131 (85.1) + 0.5 16 (10.1) 13 ( 8.4) + 1 10 ( 6.3) 10 ( 6.5) + bili (median [IQR]) 1.40 [0.80, 3.20] 1.30 [0.72, 3.60] 0.842 nonnorm + chol (median [IQR]) 315.50 [247.75, 417.00] 303.50 [254.25, 377.00] 0.544 nonnorm + albumin (mean (sd)) 3.52 (0.44) 3.52 (0.40) 0.874 + copper (median [IQR]) 73.00 [40.00, 121.00] 73.00 [43.00, 139.00] 0.717 nonnorm + alk.phos (median [IQR]) 1214.50 [840.75, 2028.00] 1283.00 [922.50, 1949.75] 0.812 nonnorm + ast (mean (sd)) 120.21 (54.52) 124.97 (58.93) 0.460 + trig (median [IQR]) 106.00 [84.50, 146.00] 113.00 [84.50, 155.00] 0.370 nonnorm + platelet (mean (sd)) 258.75 (100.32) 265.20 (90.73) 0.555 + protime (mean (sd)) 10.65 (0.85) 10.80 (1.14) 0.197 + stage (%) 0.205 exact + 1 12 ( 7.6) 4 ( 2.6) + 2 35 (22.2) 32 (20.8) + 3 56 (35.4) 64 (41.6) + 4 55 (34.8) 54 (35.1) ``` Installation ------------------------------------------------------------------------------- -Installing tableone --------------------- The tableone package for R is still in development, and is not available from the CRAN, yet. You can install it using one of the following ways. The archive file for point releases are available from the following URL: