type_freq and type_freqs retrieve the frequency of all or
some of the items of a freqlist object.
Usage
type_freqs(x, types = NULL, with_names = FALSE, ...)
type_freq(x, types = NULL, with_names = FALSE, ...)Arguments
- x
Object of class
freqlist.- types
NULLor a character vector or an object of the classtypes.If the argument
typesisNULL, then the frequencies of all the items inxare returned, in the order in which these items appear inx.If the argument
typesis a character vector or an object of the classtypes, then only the frequencies (inx) of the items intypesare given, in the order in which these items appear intypes. For all items intypesthat do not occur inx, a frequency of zero is returned.- with_names
Logical. Whether or not the items in the output should be given names. If
with_namesisTRUE, then the names of the types in the frequency list are used as names.- ...
Additional arguments.
Examples
(flist <- freqlist("The man and the mouse.", as_text = TRUE))
#> Frequency list (types in list: 4, tokens in list: 5)
#> rank type abs_freq nrm_freq
#> ---- ----- -------- --------
#> 1 the 2 4000
#> 2 and 1 2000
#> 3 man 1 2000
#> 4 mouse 1 2000
type_freqs(flist) # frequencies of all items
#> [1] 2 1 1 1
type_names(flist) # names of all items
#> [1] "the" "and" "man" "mouse"
type_freqs(flist, with_names = TRUE) # frequencies of all types, with names
#> the and man mouse
#> 2 1 1 1
type_freqs(flist, c("man", "the")) # frequencies of specific items ...
#> [1] 1 2
type_freqs(flist, c("the", "man")) # ... in the requested order
#> [1] 2 1
type_freq(flist, "the") # frequency of one item
#> [1] 2
# frequencies of specific items can also be printed using subsetting
flist[c("the", "man")]
#> Frequency list (types in list: 2, tokens in list: 3)
#> <total number of tokens: 5>
#> rank orig_rank type abs_freq nrm_freq
#> ---- --------- ---- -------- --------
#> 1 1 the 2 4000
#> 2 3 man 1 2000
flist["the"]
#> Frequency list (types in list: 1, tokens in list: 2)
#> <total number of tokens: 5>
#> rank orig_rank type abs_freq nrm_freq
#> ---- --------- ---- -------- --------
#> 1 1 the 2 4000
