harrelfe / Hmisc

Harrell Miscellaneous
Other
208 stars 81 forks source link

Problem with latex function in Hmisc_4.0-0 #59

Closed Niclase78 closed 7 years ago

Niclase78 commented 7 years ago

Hi, since Hmisc_4.0-0 latex on a summary.formula object behaves strange not showing lower/upper quartile and absolute numbers in paranthesis after percentages (latex on a summaryM obect works fine).

Below is an example:

library(Hmisc)

options(digits=3) set.seed(173) sex <- factor(sample(c("m","f"), 500, rep=TRUE)) age <- rnorm(500, 50, 5) treatment <- factor(sample(c("Drug","Placebo"), 500, rep=TRUE))

Generate some data

symp <- c('Headache','Stomach Ache','Hangnail', 'Muscle Ache','Depressed') symptom1 <- sample(symp, 500,TRUE) symptom2 <- sample(symp, 500,TRUE) symptom3 <- sample(symp, 500,TRUE) Symptoms <- mChoice(symptom1, symptom2, symptom3, label='Primary Symptoms')

Use summary.formula

f <- summary(treatment ~ age + sex + Symptoms, method="reverse", test=TRUE) f

Print in R looks ok

temp <- latex(f)

Find f.tex and see that it only shows median values for age and percentages for categorical values (i.e. no absolute numbers in paranthesis)

Hope it's an easy fix.

/ Niclas

harrelfe commented 7 years ago

This is a definite error, which is fixed for the next release to CRAN expected 2016-11-25. You can get corrected source code in summary.formula.s on github. If you use linux a new version of Hmisc with this correct is at http://data.vanderbilt.edu/fh/attach/Hmisc_4.0-1.tar.gz Thanks for the example that made it easy to find the bug.