as_types | R Documentation |
This function coerces an object, such as a character vector, to an object of
class types
.
as_types(x, remove_duplicates = TRUE, sort = TRUE, ...)
x |
Object to coerce |
remove_duplicates |
Logical. Should duplicates be removed from |
sort |
Logical. Should |
... |
Additional arguments (not implemented) |
An object of the class types
, which is based on a character vector.
It has additional attributes and methods such as:
base print()
, as_data_frame()
, sort()
and
base::summary()
(which returns the number of items and of unique items),
tibble::as_tibble()
,
the n_types()
getter and the explore()
method,
subsetting methods such as keep_types()
, keep_pos()
, etc. including []
subsetting (see brackets).
An object of class types
can be merged with another by means of types_merge()
,
written to file with write_types()
and read from file with write_types()
.
types()
toy_corpus <- "Once upon a time there was a tiny toy corpus. It consisted of three sentences. And it lived happily ever after." flist <- freqlist(toy_corpus, re_token_splitter = "\\W+", as_text = TRUE) print(flist, n = 1000) (sel_types <- as_types(c("happily", "lived", "once"))) keep_types(flist, sel_types) tks <- tokenize(toy_corpus, re_token_splitter = "\\W+") print(tks, n = 1000) tks[3:12] # idx is relative to selection head(tks) # idx is relative to selection tail(tks) # idx is relative to selection
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.