Changing summary variables returned using Hmisc summary ()

Is there an easy way to get to the traditional quartiles returned summary.formulausing method="reverse"of Hmisc R library? I would like to get Average / SD + Min / Max for each of my continuous variables, but failed. You can pass a call to a special function through an argument fun, but it does not work when method="reverse".

+3
source share
3 answers

The answer is no. The author of the package decided (as he points out in a Gnark post) that the minimum, maximum, and standard error (rephrasing) is "certainly not descriptive" of continuous variables by the categorical group.

prmsd=TRUE print.summary.formula.reverse, , min max.

> Data <- data.frame(y=sample(1:2,20,TRUE),x=rnorm(20))
> print(summary.formula(y ~ x,data=Data,method="reverse"),prmsd=TRUE)


Descriptive Statistics by y

+-+---------------------------------------------------------+---------------------------------------------------------+
| |1                                                        |2                                                        |
| |(N=11)                                                   |(N=9)                                                    |
+-+---------------------------------------------------------+---------------------------------------------------------+
|x|-0.5382053/-0.3375862/ 0.3093839  -0.1434995+/- 1.1113628|-0.4464168/-0.1677906/ 0.3007129   0.1234988+/- 0.9666382|
+-+---------------------------------------------------------+---------------------------------------------------------+
+1

Arf... summary.formula() Hmisc, , Mean SD , . print(), .

library(Hmisc)
df <- data.frame(g=sample(LETTERS[1:3], 100, rep=TRUE), replicate(3, rnorm(100)))
s <- summary(g ~ ., method="reverse", data=df)
latex(s, prmsd=TRUE, digits=2)  # replace latex by print to output inline

:

alt text

+3

Should it be in the Hmisc package? If you have a dataframe of continuous variables, you can get the same result by simply using the reshape package:

df <- data.frame(a=rnorm(100),b=rnorm(100),c=rnorm(100))

f.summary <- function(x) {
x <- melt(x)
x <- cast(x, variable ~ ., c(mean, sd, min, max))
return(x)
} 

f.summary(df)

NTN

+2
source

Source: https://habr.com/ru/post/1764897/


All Articles