Convert a krpoltext data.table to a quanteda corpus
Source:R/as_quanteda_corpus.R
as_quanteda_corpus.RdCreates a quanteda::corpus() object from a data.table loaded by
load_campaign_booklet() or load_party_statements(). The text column
is used as the document text; all other columns become document-level
variables (docvars).
Arguments
- x
A
data.table(ordata.frame) with at least atextcolumn.- text_field
Character; name of the column containing document text. Defaults to
"text".- docid_field
Character or
NULL; name of the column to use as document IDs. IfNULL, row numbers are used.- ...
Additional arguments passed to
quanteda::corpus().
Examples
if (FALSE) { # \dontrun{
ps <- load_party_statements()
corp <- as_quanteda_corpus(ps)
# Use a subset
ps_2020 <- get_docs("party_statements", year = 2020)
corp_2020 <- as_quanteda_corpus(ps_2020, docid_field = "id")
} # }