StringFrequency

class StringFrequency(data: Collection<String>? = null, name: String? = null, val limitSet: Set<String>? = null) : IdentityIfc

This class tabulates the frequency associated with the strings presented to it via the collect() method. For every unique string presented a count is maintained. There could be space/time performance issues if the number of different strings presented is large. Use the limit set to limit the values that can be observed. If the presented strings are not in the limiting set, then they are counted as "Other".

This class can be useful for tabulating a discrete histogram over the values (strings) presented.

Author

rossetti

Parameters

name

a name for the instance

data

an array of data to tabulate

limitSet

a set of strings that limit what is to be counted. If null, there is no limit. That is, every unique string presented is tabulated.

Constructors

Link copied to clipboard
constructor(data: Collection<String>? = null, name: String? = null, limitSet: Set<String>? = null)

Types

Link copied to clipboard
inner class Cell(val string: String) : Comparable<StringFrequency.Cell>

Holds the values and their counts

Properties

Link copied to clipboard

Returns an array of size numberOfCells containing the frequencies for each string observed. The 0th element is the frequency for the string stored at element 0 of the array returned by the values property

Link copied to clipboard
open override val id: Int
Link copied to clipboard
open override var label: String?
Link copied to clipboard
val limitSet: Set<String>? = null
Link copied to clipboard
open override val name: String
Link copied to clipboard

Returns the number of cells tabulated This is also the total number of different strings observed

Link copied to clipboard
Link copied to clipboard

Returns an array of size numberOfCells containing the proportion by value. The 0th element is the proportion for the value stored at element 0 of the array returned by the values property, etc.

Link copied to clipboard

Returns Map holding the string and cumulative proportions as elements in the map

Link copied to clipboard

Returns Map holding the observed strings and frequencies within the map

Link copied to clipboard

Returns Map holding the strings and associated proportions.

Link copied to clipboard

Returns a list of size numberOfCells containing the observed strings in the order in which they were observed. The 0th element of the array contains the first string observed, 1st element the next unique string, etc.

Link copied to clipboard

Functions

Link copied to clipboard

Returns a copy of the cells in a list.

Link copied to clipboard

Returns a copy of the cells in a list ordered by the count of each cell, 0th element is cell with the largest count, etc

Link copied to clipboard
fun collect(thing: Any)

Converts the thing via toString() and tabulates the observed string.

fun collect(strings: Array<String>)
fun collect(strings: Collection<String>)

fun collect(string: String)

Tabulates the count of the number of unique strings presented.

Link copied to clipboard

Returns the cumulative frequency up to an including the string

Link copied to clipboard

Returns the cumulative proportion up to an including the supplied string

Link copied to clipboard

Interprets the elements of x[] as values and returns an array representing the frequency for each value

Link copied to clipboard
fun frequency(string: String): Double

Returns the current frequency for the provided string

Link copied to clipboard
fun frequencyData(sortedByCount: Boolean = false): List<StringFrequencyData>

Returns the data associated with the tabulation.

Link copied to clipboard
fun frequencyPlot(proportions: Boolean = false): StringFrequencyPlot

Creates a plot for the integer frequencies. The parameter, proportions indicates whether proportions (true) or frequencies (false) will be shown on the plot. The default is false.

Link copied to clipboard
fun proportion(string: String): Double

Gets the proportion of the observations that are equal to the supplied string

Link copied to clipboard
fun reset()

Resets the statistical collection

Link copied to clipboard
open override fun toString(): String