Learn R Programming

⚠️There's a newer version (4.2.0) of this package.Take me there.

About

An R package for managing and analyzing text, created by Kenneth Benoit. Supported by the European Research Council grant ERC-2011-StG 283794-QUANTESS.

For more details, see https://quanteda.io.

How to Install

The normal way from CRAN, using your R GUI or

install.packages("quanteda") 

Or for the latest development version:

# devtools package required to install quanteda from Github 
devtools::install_github("quanteda/quanteda") 

Because this compiles some C++ and Fortran source code, you will need to have installed the appropriate compilers.

If you are using a Windows platform, this means you will need also to install the Rtools software available from CRAN.

If you are using macOS, you should install the macOS tools, namely the Clang 6.x compiler and the GNU Fortran compiler (as quanteda requires gfortran to build). If you are still getting errors related to gfortran, follow the fixes here.

How to Use

See the quick start guide to learn how to use quanteda.

How to cite

Benoit, Kenneth, Kohei Watanabe, Haiyan Wang, Paul Nulty, Adam Obeng, Stefan Müller, and Akitaka Matsuo. (2018) “quanteda: An R package for the quantitative analysis of textual data”. Journal of Open Source Software. 3(30), 774. https://doi.org/10.21105/joss.00774.

For a BibTeX entry, use the output from citation(package = "quanteda").

Leaving Feedback

If you like quanteda, please consider leaving feedback or a testimonial here.

Contributing

Contributions in the form of feedback, comments, code, and bug reports are most welcome. How to contribute:

Copy Link

Version

Install

install.packages('quanteda')

Monthly Downloads

24,111

Version

1.5.0

License

GPL-3

Maintainer

Kenneth Benoit

Last Published

July 4th, 2019

Functions in quanteda (1.5.0)

as.corpus.corpuszip

Coerce a compressed corpus to a standard corpus
as.dfm

Coercion and checking functions for dfm objects
as.dist.dist

Coerce a dist into a dist
affinity

Internal function to fit the likelihood scaling mixture model.
as.dictionary

Coercion and checking functions for dictionary objects
as.data.frame.dfm

Convert a dfm to a data.frame
as.fcm

Coercion functions for fcm objects
View

View methods for quanteda
as.coefficients_textmodel

Coerce various objects to coefficients_textmodel This is a helper function used in summary.textmodel_*.
as.statistics_textmodel

Coerce various objects to statistics_textmodel
check_font

Check if font is available on the system
as.corpus

coerce a compressed corpus to a standard corpus
as.summary.textmodel

Assign the summary.textmodel class to a list
compute_mattr

Compute the Moving-Average Type-Token Ratio (MATTR)
corpus_segment

Segment texts on a pattern match
compute_lexdiv_stats

Compute lexical diversity from a dfm or tokens
corpus_sample

Randomly sample documents from a corpus
data_corpus_irishbudget2010

Irish budget speeches from 2010
as.matrix.dist_selection

Coerce a dist_selection object to a matrix
convert

Convert a dfm to a non-quanteda format
as.matrix.simil

Coerce a simil object into a matrix
corpus-class

Base method extensions for corpus objects
as.list.dist_selection

Coerce a dist_selection object into a list
as.matrix,textstat_simil_sparse-method

as.matrix method for textstat_simil_sparse
as.igraph

Convert an fcm to an igraph object
as.list.dist

Coerce a dist object into a list
dfm-internal

Internal functions for dfm objects
data-deprecated

Datasets with deprecated or defunct names
corpus_subset

Extract a subset of a corpus
coef.textmodel_ca

Extract model coefficients from a fitted textmodel_ca object
data-internal

Internal data sets
corpus_trim

Remove sentences based on their token lengths or a pattern match
as.tokens

Coercion, checking, and combining functions for tokens objects
as.network

redefinition of network::as.network()
corpus

Construct a corpus object
corpus_reshape

Recast the document units of a corpus
as.yaml

Convert quanteda dictionary objects to the YAML format
dfm_tolower

Convert the case of the features of a dfm and combine
docvars

Get or set document-level variables
dfm_trim

Trim a dfm using frequency threshold-based feature selection
data_dfm_lbgexample

dfm from data in Table 1 of Laver, Benoit, and Garry (2003)
escape_regex

Internal function for select_types() to escape regular expressions
data_corpus_dailnoconf1991

Confidence debate from 1991 Irish Parliament
data_corpus_inaugural

US presidential inaugural address texts
bootstrap_dfm

Bootstrap a dfm
compute_msttr

Compute the Mean Segmental Type-Token Ratio (MSTTR)
attributes<-

Function extending base::attributes()
dfm-class

Virtual class "dfm" for a document-feature matrix
convert-wrappers

Convenience wrappers for dfm convert
data_dictionary_LSD2015

Lexicoder Sentiment Dictionary (2015)
fcm

Create a feature co-occurrence matrix
data_char_ukimmig2010

Immigration-related sections of 2010 UK party manifestos
data_char_sampletext

A paragraph of text for testing various text-based functions
generate_groups

Generate a grouping vector from docvars
fcm_sort

Sort an fcm in alphabetical order of the features
flatten_dictionary

Flatten a hierarchical dictionary into a list of character vectors
featnames

Get the feature labels from a dfm
predict.textmodel_affinity

Prediction for a fitted affinity textmodel
predict.textmodel_nb

Prediction from a fitted textmodel_nb object
diag2na

convert same-value pairs to NA in a textstat_proxy object
is_regex

Internal function for select_types() to check if a string is a regular expression
dfm_weight

Weight the feature frequencies in a dfm
dfm

Create a document-feature matrix
dfm_match

Match the feature set of a dfm to given feature names
print.statistics_textmodel

Implements print methods for textmodel_statistics
groups

Grouping variable(s) for various functions
dfm_group

Combine documents in a dfm by a grouping variable
dfm_replace

Replace features in dfm
dfm_sort

Sort a dfm by frequency of one or more margins
summary.textmodel_wordfish

summary method for textmodel_wordfish
slots<-

Function to assign multiple slots to a S4 object
print.summary.textmodel

print method for summary.textmodel
settings

Get or set the corpus settings
as.matrix.dfm

Coerce a dfm to a matrix or data.frame
cbind.dfm

Combine dfm objects by Rows or Columns
dfm_split_hyphenated_features

Split a dfm's hyphenated features into constituent parts
char_tolower

Convert the case of character objects
corpus_trimsentences

Remove sentences based on their token lengths or a pattern match
is_glob

Check if patterns contains glob wildcard
create

Utility function to create a object with new set of attributes
head.dfm

Return the first or last part of a dfm
fcm-class

matrix2fcm

Converts a Matrix to a fcm
head.corpus

Return the first or last part of a corpus
expand

Simpler and faster version of expand.grid() in base package
textmodel_ca

Correspondence analysis of a document-feature matrix
summary_character

Summary statistics on a character vector
textmodel_lsa-postestimation

Post-estimations methods for textmodel_lsa
textplot_xray

Plot the dispersion of key word(s)
is_indexed

Check if a glob pattern is indexed by index_types
texts

Get or assign corpus texts
textstat_dist_old

Similarity and distance computation between documents or features
predict.textmodel_wordfish

Prediction from a textmodel_wordfish method
print.textmodel_wordfish

print method for a wordfish model
nest_dictionary

Utility function to generate a nested list
merge_dictionary_values

Internal function to merge values of duplicated keys
quanteda-package

An R package for the quantitative analysis of textual data
predict.textmodel_wordscores

Predict textmodel_wordscores
nfeature

Defunct form of nfeat
dfm_lookup

Apply a dictionary to a dfm
keyness

Compute keyness (internal functions)
nsyllable

Count syllables in a text
tokens_serialize

Function to serialized list-of-character tokens
tf

deprecated name for dfm_weight
tokens_split

Split tokens by a separator pattern
friendly_class_undefined_message

Print friendly object class not defined message
dfm_select

Select features from a dfm or fcm
format_sparsity

format a sparsity value for printing
docnames

Get or set document names
docfreq

Compute the (weighted) document frequency of a feature
dfm_sample

Randomly sample documents or features from a dfm
nscrabble

Count the Scrabble letter values of text
dfm2lsa

Convert a dfm to an lsa "textmatrix"
nsentence

Count the number of sentences
ntoken

Count the number of tokens or types
pattern

Pattern for feature, token and keyword matching
scrabble

Deprecated name for nscrabble
reexports

Objects exported from other packages
search_glob

Select types without performing slow regex search
pattern2id

Convert regex and glob patterns to type IDs or fixed patterns
remove_empty_keys

Utility function to remove empty keys
tokens_wordstem

Stem the terms in an object
tokens_tortl

[Experimental] Change direction of words in tokens
quanteda_options

Get or set package options for quanteda
phrase

Declare a compound character to be a sequence of separate pattern matches
pattern2list

Convert various input as pattern to a vector used in tokens_select, tokens_compound and kwic.
dfm_compress

Recombine a dfm or fcm by combining identical dimension elements
set_dfm_dimnames<-

Internal functions to set dimnames
search_index

Internal function for select_types to search the index using fastmatch.
read_dict_functions

Internal functions to import dictionary files
set_dfm_slots

Set values to a dfm's S4 slots
lowercase_dictionary_values

Internal function to lowercase dictionary values
dictionary

Create a dictionary
dictionary2-class

Coerce a dictionary object into a list
dfm_tfidf

Weight a dfm by tf-idf
dfm_subset

Extract a subset of a dfm
summary.corpus

Summarize a corpus
set_fcm_slots

Set values to a fcm's S4 slots
textmodel_affinity

Class affinity maximum likelihood text scaling model
textmodel_affinity-internal

Internal methods for textmodel_affinity
split_values

Internal function for special handling of multi-word dictionary values
summary.textmodel_nb

summary method for textmodel_nb objects
summary.character

summary.character method to override the network::summary.character()
textplot_influence

Influence plot for text scaling models
textmodel_wordshoal

Wordshoal text model (redirect)
tokens_compound

Convert token sequences into compound tokens
tokens_chunk

Segment tokens object by chunks of a given size
kwic

Locate keywords-in-context
head.textstat_proxy

Return the first or last part of a textstat_proxy object
influence.predict.textmodel_affinity

Compute feature influence from a predicted textmodel_affinity object
list2dictionary

Internal function to convert a list to a dictionary
ndoc

Count the number of documents or features
metadoc

Get or set document-level meta-data
matrix2dfm

Converts a Matrix to a dfm
message_error

Return an error message
metacorpus

Get or set corpus metadata
textplot_keyness

Plot word keyness
textplot_network

Plot a network of feature co-occurrences
tokens_recompile

recompile a serialized tokens object
tokens_ngrams

Create ngrams and skipgrams from tokens
textstat_proxy

[Experimental] Compute document/feature proximity
textstat_entropy

Compute entropy of documents or features
textstat_readability

Calculate readability
textstat_collocations

Identify and score multi-word expressions
tokens

Tokenize a set of texts
textstat_frequency

Tabulate feature frequencies
textstat_keyness

Calculate keyness statistics
tfidf

print.coefficients_textmodel

Print methods for textmodel features estimates This is a helper function used in print.summary.textmodel.
tokens_group

Recombine documents tokens by groups
tokens_replace

Replace tokens in a tokens object
print.dist_selection

Print a dist_selection object
print.dfm

Print a dfm object
print.phrases

Print a phrase object
textmodel_wordscores

Wordscores text model
tokens_subset

Extract a subset of a tokens
textmodel_wordfish

Wordfish text model
tokens_sample

Randomly sample documents from a tokens object
tokens_tolower

Convert the case of tokens
unused_dots

Raise warning of unused dots
tokens_lookup

Apply a dictionary to a tokens object
replace_dictionary_values

Internal function to replace dictionary values
wordcloud

Internal function for textplot_wordcloud
valuetype

Pattern matching using valuetype
wordcloud_comparison

Internal function for textplot_wordcloud
textmodel_nb

Naive Bayes classifier for texts
spacyr-methods

Extensions for and from spacy_parse objects
textmodel_lsa

Latent Semantic Analysis
sparsity

Compute the sparsity of a document-feature matrix
sample_bygroup

Sample a vector by a group
textplot_wordcloud

Plot features as a wordcloud
textplot_scale1d

Plot a fitted scaling model
topfeatures

Identify the most frequent features in a dfm
types

Get word types from a tokens object
textstat_lexdiv

Calculate lexical diversity
textstat_proxy-class

textstat_simil/dist classes
unlist_integer

Unlist a list of integer vectors safely
tokens_select

Select or remove tokens from a tokens object
textstat_simil

Similarity and distance computation between documents or features
tokens_segment

Segment tokens object by patterns
textstat_select

Select rows of textstat objects by glob, regex or fixed patterns
unlist_character

Unlist a list of character vectors safely