sample_tfl: Incremental Samples from a Type Frequency List (zipfR)

Description Usage Arguments Details Value See Also Examples

Description

Compute incremental random samples from a type frequency list (an object of class tfl).

Usage

1
  sample.tfl(obj, N, force.list=FALSE)

Arguments

obj

an object of class tfl, representing a type frequency list

N

a vector of non-negative integers in increasing order, the sample sizes for which incremental samples will be generated

force.list

if TRUE, the return value will always be a list of tfl objects, even if N is just a single integer

Details

The current implementation is reasonably efficient, but will be rather slow when applied to very large type frequency lists.

Value

If N is a single integer (and the force.list flag is not set), a tfl object representing a random sample of size N from the type frequency list obj.

If N is a vector of length greater one, or if force.list=TRUE, a list of tfl objects representing incremental random samples of the specified sizes N. Incremental means that each sample is a superset of the preceding sample.

See Also

tfl for more information about type frequency lists

sample.spc is an analogous function for frequency spectra (objects of class spc)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## load Brown tfl
data(Brown.tfl)
summary(Brown.tfl)

## sample a tfl of 100k tokens
MiniBrown.tfl <- sample.tfl(Brown.tfl,1e+5)
summary(MiniBrown.tfl)

## if we repat, we get a different sample
MiniBrown.tfl <- sample.tfl(Brown.tfl,1e+5)
summary(MiniBrown.tfl)

zipfR documentation built on Jan. 8, 2021, 2:37 a.m.