ExpCTable.Rdthis function will automatically select categorical variables and generate frequency or cross tables based on the user inputs. Output includes counts, percentages, row total and column total.
ExpCTable(data, Target = NULL, margin = 1, clim = 10, nlim = 10, round = 2, bin = 3, per = FALSE)
| data | dataframe or matrix |
|---|---|
| Target | target variable (dependent variable) if any. Default NULL |
| margin | margin of index, 1 for row based proportions and 2 for column based proportions |
| clim | maximum categories to be considered for frequency/custom table. Variables will be dropped if unique levels are higher than ‘clim’ for class factor/character variable. Default value is 10. |
| nlim | numeric variable unique limits. Default ‘nlim’ values is 3, table excludes the numeric variables which is having greater than ‘nlim’ unique values |
| round | round off |
| bin | number of cuts for continuous target variable |
| per | percentage values. Default table will give counts. |
Frequency tables, Cross tables
Columns description for frequency tables:
Variable - Variable name
Valid - Variable values
Frequency - Frequency
Percent - Relative frequency
CumPercent - Cumulative sum of relative frequency
Columns description for custom tables:
Variable - Variable name
Category - Variable values
Count - Number of counts
Per - Percentages
Total - Total count
this function provides both frequency and custom tables for all categorical features. And ouput will be generated in data frame
# Frequency table ExpCTable(mtcars,Target=NULL,margin=1,clim=10,nlim=3,bin=NULL,per=FALSE)#> Variable Valid Frequency Percent CumPercent #> 1 cyl 4 11 34.38 34.38 #> 2 cyl 6 7 21.88 56.26 #> 3 cyl 8 14 43.75 100.01 #> 4 cyl TOTAL 32 NA NA #> 5 vs 0 18 56.25 56.25 #> 6 vs 1 14 43.75 100.00 #> 7 vs TOTAL 32 NA NA #> 8 am 0 19 59.38 59.38 #> 9 am 1 13 40.62 100.00 #> 10 am TOTAL 32 NA NA #> 11 gear 3 15 46.88 46.88 #> 12 gear 4 12 37.50 84.38 #> 13 gear 5 5 15.62 100.00 #> 14 gear TOTAL 32 NA NA# Crosstbale for Mtcars data ExpCTable(mtcars,Target="gear",margin=1,clim=10,nlim=3,bin=NULL,per=FALSE)#> VARIABLE CATEGORY gear:3 gear:4 gear:5 TOTAL #> 1 cyl 4 1 8 2 11 #> 2 cyl 6 2 4 1 7 #> 3 cyl 8 12 0 2 14 #> 4 cyl TOTAL 15 12 5 32 #> 5 vs 0 12 2 4 18 #> 6 vs 1 3 10 1 14 #> 7 vs TOTAL 15 12 5 32 #> 8 am 0 15 4 0 19 #> 9 am 1 0 8 5 13 #> 10 am TOTAL 15 12 5 32 #> 11 gear 3 15 0 0 15 #> 12 gear 4 0 12 0 12 #> 13 gear 5 0 0 5 5 #> 14 gear TOTAL 15 12 5 32