strengejacke / sjPlot

sjPlot - Data Visualization for Statistics in Social Science
https://strengejacke.github.io/sjPlot
608 stars 91 forks source link

Change variable headers in tables when no labels #237

Open AlexSananka opened 7 years ago

AlexSananka commented 7 years ago

sjtab displays tables really nicely when the data has variable and value labels. However, when I use a data frame without column labels the headers are not very clear. Example:

dat <- data.frame(x = rep(1:5, 4), y = rep(c("a", "b", "c", "d"), 5), z = rnorm(20), f = rep(1:2,10))
dat %>% select(x, y, f) %>% group_by(f) %>% sjtab(fun="xtab")

image

Also, I think because my grouping factor has no value labels, I don't get any titles on the different tables.

I know that these were mainly designed for labelled data but is it possible that if there are no labels it could use the column names and values by default to produce the headers and titles?

AlexSananka commented 7 years ago

Actually, I've seen that when the grouping variable is a factor it does give nice titles for the tables using the values, which is great. However, now I get quite strange headers for the variables in the tables. Example:

dat <- data.frame(x = rep(1:5, 4), y = rep(c("a", "b", "c", "d"), 5), z = rnorm(20), f = factor(rep(1:2,10)))
dat %>% select(x, y, f) %>% group_by(f) %>% sjtab(fun="xtab")

image

Any idea why this is happening?

strengejacke commented 6 years ago

I think this is one of the next greater revisions that need to be done: revising the table (and plot) functions for descriptives / frequencies...

CG-Rodriguez commented 5 years ago

Yes! It would be really appreciated to count with a function for descriptives that combines sjmisc::frq, group_by() and summarise() (d.h., mean/SD calculations for continuous variables).

strengejacke commented 5 years ago

Yes! It would be really appreciated to count with a function for descriptives that combines sjmisc::frq, group_by() and summarise() (d.h., mean/SD calculations for continuous variables).

Not sure, but isn't sjmisc::descr() doing that, if I understood right?