StatBean Name: Tabulation

Purpose: Tabulates a single column of data. For categorical data, finds the frequency of all unique values. For numeric data, finds the frequency within specified intervals.

DataSource: any.

Read/Write Properties
NameTypeDescriptionPossible ValuesDefault Value
bydoubleWidth of intervals (continuous data only).Any double value > 0.0.1
caseSensitivebooleanWhether placing data values into classes is case sensitive.true,falsefalse
combineClassCriteriondoubleValue at or below which classes are combined.any double1.0
combineClassLabelStringLabel for the combined class, if any.Any string."Other"
combineClassMethodStringMethod for combining classes."None",
"Frequency",
"Percentage"
"None"
dataTypeStringThe type of data to be tabulated. If Categorical, shows unique values. If Discrete, shows all integer values. If Continuous, shows number of values within intervals."Categorical",
"Discrete",
"Continuous"
"Categorical"
fromdoubleLower limit for first interval (numeric data only).Any double value.0.0
todoubleUpper limit for last interval (numeric data only).Double value > from.1.0
xVariableNameStringThe name of the first column with data values to be tabulated.Any string."X"
yVariableNameStringThe name of the second column (if any) with data values to be tabulated.Any string.""

Other Public Methods
NameDescriptionArgumentsReturn Value
String getLabels()Returns the labels for each class, separated by a tab character.None.Labels.
int getCountAbove()For Continuous datatype, the number of data values greater than the last class.None.Number of values.
int getCountBelow()For Continuous datatype, the number of data values less than the first class.None.Number of values.
double getLowerLimit()For Continuous and Discrete datatypes, the lower limit of the first class.None.Lower limit.
int getMean()For Continuous and Discrete datatypes, the sample mean for the first variable.None.Mean.
int getMean2()For Continuous and Discrete datatypes, the sample mean for the second variable.None.Mean.
int getNumberOfClasses()Returns the number of classes k into which the data was tabulated.None.Number of classes.
int getSigma()For Continuous and Discrete datatypes, the sample standard deviation for the first variable.None.Standard deviation.
int getSigma2()For Continuous and Discrete datatypes, the sample standard deviation for the second variable.None.Standard deviation.
int getTotalCount()Returns the sum of the frequencies for the first variable.None.Total count.
int getTotalCount2()Returns the sum of the frequencies for the second variable.None.Total count.
double getUpperLimit()For Continuous and Discrete datatypes, the upper limit of the last class.None.Upper limit.

Output Variables
NameDescription
FrequencyNumbers of data values in each class for the first variable.
Frequency2Numbers of data values in each class for the second variable.
LabelLabels for each class.
PercentagePercentage of data values in each class for the first variable.
Percentage2Percentage of data values in each class for the second variable.

Code Sample

//create a datasource bean
FileDataSource fileDataSource1 = new STATBEANS.FileDataSource();

//set the file name to be read
fileDataSource1.setFileName("c:\\statbeans\\samples\\cardata.txt");

//create a calculation bean
Tabulation tabulation1 = new STATBEANS.Tabulation();

//set the column to be tabulated
tabulation1.setXVariableName("year");

//set the desired ordering for the tabulation
tabulation1.setOrdering("Alphabetical");

//create a table bean
FrequencyTable frequencyTable1 = new STATBEANS.FrequencyTable();

//create 2 plot beans
Barchart barchart1 = new STATBEANS.Barchart();
Piechart piechart1 = new STATBEANS.Piechart();

//set the display name
frequencyTable1.setClassName("Year");
barchart1.setClassName("Year");
piechart1.setClassName("Year");

//scale the axis by class percentage
barchart1.setScaleByPercentage(true);

//request labels at the ends of the bars
barchart1.setBarLabels("Frequency");

//add lines from slices
piechart1.setLinesToLabels(true);

//offset a slice
piechart1.setHighlightSlice1(5);

//make the calculation bean a listener for changes in the FileDataSource bean
fileDataSource1.addDataChangeListener(tabulation1.listenerForDataChange);

//make the table and plot beans listeners for changes in the calculation bean
tabulation1.addDataChangeListener(frequencyTable1.listenerForDataChange);
tabulation1.addDataChangeListener(barchart1.listenerForDataChange);
tabulation1.addDataChangeListener(piechart1.listenerForDataChange);

//instruct the fileDataSource bean to read the file
fileDataSource1.readData();