Learn R Programming

SmartEDA (version 0.3.10)

ExpCTable: Function to create frequency and custom tables

Description

this 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.

Usage

ExpCTable(
  data,
  Target = NULL,
  margin = 1,
  clim = 10,
  nlim = 10,
  round = 2,
  bin = 3,
  per = FALSE,
  weight = NULL
)

Value

Frequency tables, Cross tables

Columns description for frequency tables:

  • Variable is Variable name

  • Valid is Variable values

  • Frequency is Frequency

  • Percent is Relative frequency

  • CumPercent is Cumulative sum of relative frequency

Columns description for custom tables:

  • Variable is Variable name

  • Category is Variable values

  • Count is Number of counts

  • Per is Percentages

  • Total is Total count

Arguments

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

weight

a vector of weights, it must be equal to the length of data

Details

this function provides both frequency and custom tables for all categorical features. And ouput will be generated in data frame

Examples

Run this code
# Frequency table
ExpCTable(mtcars, Target = NULL, margin = 1, clim = 10, nlim = 3, bin = NULL, per = FALSE)
# Crosstbale for Mtcars data
ExpCTable(mtcars, Target = "gear", margin = 1, clim = 10, nlim = 3, bin = NULL, per = FALSE)
# Weighted frequecncy for Mtcars data
ExpCTable(mtcars,  margin = 1, clim = 10, nlim = 3, bin = NULL, per = FALSE, weight = "wt")

Run the code above in your browser using DataLab