Type Frequency Lists (zipfR)
tfl objects are used to represent
a type frequency list, which specifies the observed frequency of each
type in a corpus. For mathematical reasons, expected type frequencies
are rarely considered.
tfl constructor function, an object can be initialized
directly from the specified data vectors. It is more common to read
a type frequency list from a disk file with
in some cases, derive it from an observed frequency spectrum with
tfl objects should always be treated as read-only.
1 2 3
integer vector of type IDs k (if omitted, natural numbers 1,2,… are assigned automatically)
vector of corresponding type frequencies f_k
optional character vector of type representations (e.g. word forms or lemmata), used for informational and printing purposes only
indicates that the type frequency list is incomplete, i.e. only contains types in a certain frequency range (typically, the lowest-frequency types may be excluded). Incomplete type frequency lists are rarely useful.
sample size and vocabulary size corresponding to the type frequency list have to be specified explicitly for incomplete lists
frequency range represented in an incomplete type frequency list (see details below)
f.max are not specified, but the list is
marked as incomplete (with
incomplete=TRUE), they are
automatically determined from the frequency vector
the assumption that all types in this frequency range are listed).
Explicit specification of either
an incomplete list. In this case, all types outside the specified
range will be deleted from the list. If
V will be determined
automatically from the input data (which is assumed to be complete),
but the resulting type frequency list will still be incomplete.
If you just want to remove types with f=0 without marking the
type frequency list as incomplete, use the option
tfl object is a data frame with the following variables:
integer type ID k
corresponding type frequency f_k
optional: character vector with type representations used for printing
The data frame always has to be sorted with respect to the
column (ascending order).
The following attributes are used to store additional information about the frequency spectrum:
sample size N and vocabulary size V corresponding to the type frequency list. For a complete list, these values could easily be determined from the
fvariable, but they are essential for an incomplete list.
TRUE, the type frequency list is incomplete, i.e. it lists only types in the frequency range given by
range of type frequencies represented in the list (should be ignored unless the
incompleteflag is set)
indicates whether or not the
typevariable is present
An object of class
tfl representing the specified type
frequency list. This object should be treated as read-only (although
such behaviour cannot be enforced in R).
Generic methods supported by
tfl objects are
Implementation details and non-standard arguments for these methods
can be found on the manpages
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
## typically, you will read a tfl from a file ## (see examples in the read.tfl manpage) ## or you can load a ready-made tfl data(Brown.tfl) summary(Brown.tfl) print(Brown.tfl) ## or create it from a spectrum (with different ids and ## no type labels) data(Brown.spc) Brown.tfl2 <- spc2tfl(Brown.spc) ## same frequency information as Brown.tfl ## but with different ids and no type labels summary(Brown.tfl2) print(Brown.tfl2) ## how to display draw a Zipf's rank/frequency plot ## by extracting frequencies from a tfl plot(sort(Brown.tfl$f,decreasing=TRUE),log="y",xlab="rank",ylab="frequency") ## simulating a tfl Zipfian.tfl <- tfl(1000/(1:1000)) plot(Zipfian.tfl$f,log="y")
Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.