Learn R Programming

quanteda.tidy (version 0.4)

mutate.corpus: Create or transform document variables

Description

mutate() adds new document variables and preserves existing ones; transmute() adds new document variables and drops existing ones. Both functions preserve the number of rows of the input. New variables overwrite existing variables of the same name.

Usage

# S3 method for corpus
mutate(.data, ...)

# S3 method for corpus transmute(.data, ...)

Value

A corpus with new or modified document variables.

Arguments

.data

a quanteda object whose document variables will be created or transformed

...

name-value pairs of expressions for document variable modification or assignment; see mutate.

Examples

Run this code
data_corpus_inaugural %>%
  mutate(fullname = paste(FirstName, President, sep = ", ")) %>%
  summary(n = 5)

data_corpus_inaugural %>%
  transmute(fullname = paste(FirstName, President, sep = ", ")) %>%
  summary(n = 5)

Run the code above in your browser using DataLab