Learn R Programming

qdap (version 0.2.5)

ngrams: Generate ngrams

Description

Transcript apply ngrams.

Usage

ngrams(text.var, grouping.var = NULL, n = 2)

Arguments

text.var
The text variable
grouping.var
The grouping variables. Default NULL generates one word list for all text. Also takes a single grouping variable or a list of 1 or more grouping variables.
n
The max number of grams calculate.

Value

  • Returns a list of:
  • rawA list of pasted single vectors of the ngrams per row.
  • groupA list of pasted vectors of ngrams grouped by grouping.var.
  • unlist1A list of a single vector of pasted ngrams per grouping.var in the order used.
  • unlist2A list of a single vector of pasted ngrams per grouping.var in alphabetical order.
  • group_nA list of a list of vectors of ngrams per grouping.var & n (not pasted).
  • allA single vector of pasted ngrams sorted alphabetically.
  • all_nA list of lists a single vectors of ngrams sorted alphabetically (not pasted).

Examples

Run this code
ngrams(DATA$state, DATA$person, 2)
ngrams(DATA$state, DATA$person, 3)
ngrams(DATA$state, , 3)
with(mraja1, ngrams(dialogue, list(sex, fam.aff), 3))

Run the code above in your browser using DataLab