This method returns the number of tokens in an object.
Usage
n_tokens(x, ...)
# S3 method for freqlist
n_tokens(x, ...)
# S3 method for tokens
n_tokens(x, ...)
Arguments
- x
An object of any of the classes for which the method is implemented.
- ...
Additional arguments.
See also
Other getters and setters:
n_types()
,
orig_ranks()
,
ranks()
,
tot_n_tokens()
,
type_names()
Examples
(tks <- tokenize("The old man and the sea."))
#> Token sequence of length 6
#> idx token
#> --- -----
#> 1 the
#> 2 old
#> 3 man
#> 4 and
#> 5 the
#> 6 sea
n_tokens(tks)
#> [1] 6
(flist <- freqlist(tks))
#> Frequency list (types in list: 5, tokens in list: 6)
#> rank type abs_freq nrm_freq
#> ---- ---- -------- --------
#> 1 the 2 3333.333
#> 2 and 1 1666.667
#> 3 man 1 1666.667
#> 4 old 1 1666.667
#> 5 sea 1 1666.667
n_tokens(flist)
#> [1] 6
n_types(flist)
#> [1] 5