Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

summary_metadata

Functions to add or retrieve corpus summary metadata


Description

Functions to add or retrieve corpus summary metadata

Usage

add_summary_metadata(x, extended = FALSE, ...)

get_summary_metadata(x, ...)

summarize_texts_extended(x, stop_words = stopwords("en"), n = 100)

Arguments

x

corpus object

...

additional arguments passed to tokens() when computing the summary information

Details

This is provided so that a corpus object can be stored with summary information to avoid having to compute this every time [summary.corpus()] is called.

So in future calls, if !is.null(meta(x, "summary", type = "system") && !length(list(...)), then summary.corpus() will simply return get_system_meta() rather than compute the summary statistics on the fly, which requires tokenizing the text.

Value

add_summary_metadata() returns a corpus with summary metadata added as a data.frame, with the top-level list element names summary.

get_summary_metadata() returns the summary metadata as a data.frame.

summarize_texts_extended() returns extended summary information.

Examples

corp <- corpus(data_char_ukimmig2010)
corp <- quanteda:::add_summary_metadata(corp)
quanteda:::get_summary_metadata(corp)

## Not run: 
# using extended summary

extended_data <- quanteda:::summarize_texts_extended(data_corpus_inaugural)

textplot_wordcloud(extended_data$top_dfm, max_words = 100)

\dontrun{
library("ggplot2")
ggplot(data.frame(all_tokens = extended_data$all_tokens), aes(x = all_tokens)) +
   geom_histogram(color = "darkblue", fill = "lightblue") +
   xlab("Total length in tokens")
}

## End(Not run)

quanteda

Quantitative Analysis of Textual Data

v3.0.0
GPL-3
Authors
Kenneth Benoit [cre, aut, cph] (<https://orcid.org/0000-0002-0797-564X>), Kohei Watanabe [aut] (<https://orcid.org/0000-0001-6519-5265>), Haiyan Wang [aut] (<https://orcid.org/0000-0003-4992-4311>), Paul Nulty [aut] (<https://orcid.org/0000-0002-7214-4666>), Adam Obeng [aut] (<https://orcid.org/0000-0002-2906-4775>), Stefan Müller [aut] (<https://orcid.org/0000-0002-6315-4125>), Akitaka Matsuo [aut] (<https://orcid.org/0000-0002-3323-6330>), William Lowe [aut] (<https://orcid.org/0000-0002-1549-6163>), Christian Müller [ctb], European Research Council [fnd] (ERC-2011-StG 283794-QUANTESS)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.