dcomtois / summarytools

R Package to Quickly and Neatly Summarize Data
504 stars 77 forks source link

descr doesn't keep column order #117

Closed zx8754 closed 4 years ago

zx8754 commented 4 years ago

Can we keep column order same as input data (related to #21):

library(dplyr)
library(summarytools)

colnames(mtcars[, 1:2])
# [1] "mpg" "cyl"

Below both give the same output:

descr(mtcars[, 2:1], stats = c("mean", "sd", "min"), headings = FALSE)
descr(mtcars[, 1:2], stats = c("mean", "sd", "min"), headings = FALSE)
#                  cyl     mpg
# ------------- ------ -------
#          Mean   6.19   20.09
#       Std.Dev   1.79    6.03
#           Min   4.00   10.40

Related SO post:

dcomtois commented 4 years ago

Hi,

There is no way currently but it's on my todo list!

dcomtois commented 4 years ago

The dev-current branch now includes an "order" parameter for descr(). Values can be one of:

If you could test it and confirm it works, I'll then close the issue. Thx.

zx8754 commented 4 years ago

@dcomtois tested on dev version, all good. Thank you.