Calculation STATBEANS®

 

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
Name Type Description Possible Values Default Value
by double Width of intervals (continuous data only). Any double value > 0. 0.1
caseSensitive boolean Whether placing data values into classes is case sensitive. true,false false
combineClassCriterion double Value at or below which classes are combined. any double 1.0
combineClassLabel String Label for the combined class, if any. Any string. "Other"
combineClassMethod String Method for combining classes. "None",
"Frequency",
"Percentage"
"None"
dataType String The 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"
from double Lower limit for first interval (numeric data only). Any double value. 0.0
to double Upper limit for last interval (numeric data only). Double value > from. 1.0
xVariableName String The name of the first column with data values to be tabulated. Any string. "X"
yVariableName String The name of the second column (if any) with data values to be tabulated. Any string. ""

Other Public Methods
Name Description Arguments Return 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
Name Description
Frequency Numbers of data values in each class for the first variable.
Frequency2 Numbers of data values in each class for the second variable.
Label Labels for each class.
Percentage Percentage of data values in each class for the first variable.
Percentage2 Percentage 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();