Tom
Tom

Reputation: 2351

Getting rid of the variable types in dfSummary output from summarytools

I have data as follows and I want to get rid of the variable type mentioned in the output(red).

library(data.table)
library(summarytools)
df1 <- fread(
    "A   B   C  iso   year   
     0   B   1  NLD   2009   
     1   A   2  NLD   2009   
     0   Y   3  AUS   2011   
     1   Q   4  AUS   2011   
     0   NA  7  NLD   2008   
     1   0   1  NLD   2008   
     0   1   3  AUS   2012",
  header = TRUE
)

x <- dfSummary(df1, labels.col=FALSE, valid.col=FALSE, na.col=FALSE, display.labels=FALSE)
stview(x)

I tried to put several options to false, without success. Any ideas?

enter image description here

Upvotes: 0

Views: 436

Answers (1)

Dominic Comtois
Dominic Comtois

Reputation: 10431

There is no built-in way to do it, but you can remove it manually:

x <- dfSummary(df1, labels.col=FALSE, valid.col=FALSE, na.col=FALSE, display.labels=FALSE)
x$Variable <- sub("\\[.+\\]", "", x$Variable)
x
Data Frame Summary  
df1  
Dimensions: 7 x 5  
Duplicates: 0  

-------------------------------------------------------------------------------
No   Variable   Stats / Values             Freqs (% of Valid)   Graph          
---- ---------- -------------------------- -------------------- ---------------
1    A          Min  : 0                   0 : 4 (57.1%)        IIIIIIIIIII    
                Mean : 0.4                 1 : 3 (42.9%)        IIIIIIII       
                Max  : 1                                                       

2    B          1. 0                       1 (16.7%)            III            
                2. 1                       1 (16.7%)            III            
                3. A                       1 (16.7%)            III            
                4. B                       1 (16.7%)            III            
                5. Q                       1 (16.7%)            III            
                6. Y                       1 (16.7%)            III            

3    C          Mean (sd) : 3 (2.1)        1 : 2 (28.6%)        IIIII          
                min < med < max:           2 : 1 (14.3%)        II             
                1 < 3 < 7                  3 : 2 (28.6%)        IIIII          
                IQR (CV) : 2 (0.7)         4 : 1 (14.3%)        II             
                                           7 : 1 (14.3%)        II             

4    iso        1. AUS                     3 (42.9%)            IIIIIIII       
                2. NLD                     4 (57.1%)            IIIIIIIIIII    

5    year       Mean (sd) : 2009.7 (1.6)   2008 : 2 (28.6%)     IIIII          
                min < med < max:           2009 : 2 (28.6%)     IIIII          
                2008 < 2009 < 2012         2011 : 2 (28.6%)     IIIII          
                IQR (CV) : 2.5 (0)         2012 : 1 (14.3%)     II             
-------------------------------------------------------------------------------

Upvotes: 1

Related Questions