rename.corpus: Rename document variables

Description Usage Arguments Examples

View source: R/rename.R

Description

rename() changes the names of individual document variables using new_name = old_name syntax; rename_with() renames columns using a function.

Usage

1
2
3
4
5
## S3 method for class 'corpus'
rename(.data, ...)

## S3 method for class 'corpus'
rename_with(.data, .fn, .cols = everything(), ...)

Arguments

.data

a quanteda object with document variables

...

For rename(): <tidy-select> Use new_name = old_name to rename selected variables.

For rename_with(): additional arguments passed onto .fn.

.fn

A function used to transform the selected .cols. Should return a character vector the same length as the input.

.cols

<tidy-select> Columns to rename; defaults to all columns.

Examples

1
2
3
4
5
6
7
8
9
data_corpus_inaugural %>%
  rename(LastName = President) %>%
  summary(n = 5)
data_corpus_inaugural %>%
  rename_with(toupper) %>%
  summary(n = 5)
data_corpus_inaugural %>%
  rename_with(toupper, starts_with("P")) %>%
  summary(n = 5)

quanteda/quanteda.tidy documentation built on April 11, 2021, 3:44 p.m.