Skip to contents

These functions merge two or more frequency lists, adding up the frequencies. In the current implementation, original ranks are lost when merging.

Usage

freqlist_merge(x, y)

freqlist_merge_all(...)

Arguments

x, y

An object of class freqlist.

...

Various objects of class freqlist or a list of objects of class freqlist.

Value

An object of class freqlist.

Examples

(flist1 <- freqlist("A first toy corpus.", as_text = TRUE))
#> Frequency list (types in list: 4, tokens in list: 4)
#> rank   type abs_freq nrm_freq
#> ---- ------ -------- --------
#>    1      a        1     2500
#>    2 corpus        1     2500
#>    3  first        1     2500
#>    4    toy        1     2500
(flist2 <- freqlist("A second toy corpus.", as_text = TRUE))
#> Frequency list (types in list: 4, tokens in list: 4)
#> rank   type abs_freq nrm_freq
#> ---- ------ -------- --------
#>    1      a        1     2500
#>    2 corpus        1     2500
#>    3 second        1     2500
#>    4    toy        1     2500
(flist3 <- freqlist("A third toy corpus.", as_text = TRUE))
#> Frequency list (types in list: 4, tokens in list: 4)
#> rank   type abs_freq nrm_freq
#> ---- ------ -------- --------
#>    1      a        1     2500
#>    2 corpus        1     2500
#>    3  third        1     2500
#>    4    toy        1     2500

freqlist_merge(flist1, flist2)
#> Frequency list (types in list: 5, tokens in list: 8)
#> rank   type abs_freq nrm_freq
#> ---- ------ -------- --------
#>    1      a        2     2500
#>    2 corpus        2     2500
#>    3    toy        2     2500
#>    4  first        1     1250
#>    5 second        1     1250

freqlist_merge_all(flist1, flist2, flist3)
#> Frequency list (types in list: 6, tokens in list: 12)
#> rank   type abs_freq nrm_freq
#> ---- ------ -------- --------
#>    1      a        3 2500.000
#>    2 corpus        3 2500.000
#>    3    toy        3 2500.000
#>    4  first        1  833.333
#>    5 second        1  833.333
#>    6  third        1  833.333
freqlist_merge_all(list(flist1, flist2, flist3)) # same result
#> Frequency list (types in list: 6, tokens in list: 12)
#> rank   type abs_freq nrm_freq
#> ---- ------ -------- --------
#>    1      a        3 2500.000
#>    2 corpus        3 2500.000
#>    3    toy        3 2500.000
#>    4  first        1  833.333
#>    5 second        1  833.333
#>    6  third        1  833.333