Skip to contents

Calculates the cooccurrence of dictionary terms in a given corpus.

Usage

matchCodes(corpus, 
              dic,
              level=1,
              remove.self=TRUE,
              quietly=FALSE)

Arguments

corpus

A quanteda corpus object.

dic

Quanteda dictionary employed in the analysis.

level

The level of the dictionary to take into account of the aggregation of co-ocurrences. The default is 1 (top level of abstraction).

remove.self

Logical. Indicates if the function should remove co-ocurrences of a theme with itself. The default is TRUE.

quietly

Logical. Indicates if the function hides the progress bar or not. The default is FALSE.

Details

The function matchCodes calculates the number of times each pair of dictionary terms co-occur in a corpus.

Value

A data.frame object containing three variables: term1, term2, and value.

Examples

# Create a corpus object
library(quanteda)
#> Package version: 4.0.1
#> Unicode version: 14.0
#> ICU version: 71.1
#> Parallel computing: disabled
#> See https://quanteda.io for tutorials and examples.
cb <- corpus(spa.inaugural)

# use the dic.pol.es dictionary
dic <- dic.pol.es

# Generates the results
d <- matchCodes(cb, dic)
#> 
  |                                                        
  |                                                  |   0%
  |                                                        
  |=====                                             |  10%
  |                                                        
  |==========                                        |  20%
  |                                                        
  |===============                                   |  30%
  |                                                        
  |====================                              |  40%
  |                                                        
  |=========================                         |  50%
  |                                                        
  |==============================                    |  60%
  |                                                        
  |===================================               |  70%
  |                                                        
  |========================================          |  80%
  |                                                        
  |=============================================     |  90%
  |                                                        
  |==================================================| 100%