kaz-yos / tableone

R package to create "Table 1", description of baseline characteristics with or without propensity score weighting
https://cran.r-project.org/web/packages/tableone/index.html
218 stars 41 forks source link

Digits argument broken #70

Closed SimonStolz closed 4 years ago

SimonStolz commented 4 years ago
## Generating data for example
set.seed(1)
x <- rnorm(50, 50, 34)
set.seed(2)
y <- rnorm(50, 70, 34)
d <- rbind(cbind(G = 1, x),
           cbind(G = 0, y)) %>% as.data.frame()

when now displaying the table, it makes no difference what digits I specify in the argument. pDigits works fine, but digits has no impact on the output. It always rounded to 2 decimal places!

print(CreateTableOne(vars = "x", strata="G", data = d), digits = 5, pDigits = 5)

x (mean (sd)) 72.35 (38.41) 53.42 (28.27) 0.00602

print(CreateTableOne(vars = "x", strata="G", data = d), digits = 1, pDigits = 5)

x (mean (sd)) 72.35 (38.41) 53.42 (28.27) 0.00602

ndevln commented 4 years ago

Hi,

print.TableOne() has no digits argument. Please use contDigits for continuos variables. Proportions (i.e. percentages) are controlled with catDigits. This behaviour was seperated to provide more flexibility.

https://www.rdocumentation.org/packages/tableone/versions/0.11.2/topics/print.TableOne

Greetings Alex

SimonStolz commented 4 years ago

Apologies - I must have mistakenly looked at the regular print() documentation! Thanks a lot Alex, this worked perfectly!