isubirana / compareGroups

R package to easily build publication-ready univariate or bivariate descriptive tables from a data set.
https://isubirana.github.io/compareGroups/
34 stars 13 forks source link

Issue with hide.no option in createTable() #1

Closed Nikita2804 closed 6 years ago

Nikita2804 commented 6 years ago

Hi,

I am trying to use compareGroups() on a dataframe variable that has only 1 level - "No". When createTable() is run on the compareGroups object using hide.no="No", the resulting output is 100% instead of 0% for the variable. Please see below, code and the resulting output

Code:

df <-data.frame(z=1:5,y="No")
df$y<-factor(df$y,levels=c("Yes","No"))
comp_df <-compareGroups(~y,data = df)
createTable(comp_df,hide.no="No")

Output:

--------Summary descriptives table ---------

____________ 
   [ALL]   N 
    N=5      
¯¯¯¯¯¯¯¯¯¯¯¯ 
y 5 (100%) 5

Can you please look into this?

Thanks, Nikita.

isubirana commented 6 years ago

Hi,

Thanks for pointing out this issue and for using the compareGroups package. We appreciate your feedback which improves the package a lot. In fact, we already have fixed this problem in compareGroups function code in the latest package version available on Github repository. You can install and download this version by typing:

library(devtools) devtools::install_github("isubirana/compareGroups")

In your example, instead of reporting 5 "yes", it reports 5 "no". So, the "hide.no" argument has no effect because in fact the "y" variable has only one level with data.

Regards,

Isaac Subirana.