encoding: Get and set encoding.

encodingR Documentation

Get and set encoding.

Description

Method for textstat objects and classes inheriting from textstat; if object is a character vector, the encoding of the corpus is returned. If called without arguments, the session character set is returned.

Usage

encoding(object)

encoding(object) <- value

## S4 method for signature 'missing'
encoding(object)

## S4 method for signature 'textstat'
encoding(object)

## S4 method for signature 'bundle'
encoding(object)

## S4 method for signature 'character'
encoding(object)

## S4 method for signature 'corpus'
encoding(object)

## S4 method for signature 'subcorpus'
encoding(object)

## S4 method for signature 'call'
encoding(object)

## S4 method for signature 'quosure'
encoding(object)

## S4 replacement method for signature 'call'
encoding(object) <- value

## S4 replacement method for signature 'quosure'
encoding(object) <- value

Arguments

object

A textstat or bundle object (or an object inheriting from these classes), or a length-one character vector specifying a corpus. If missing, the method will return the session character set.

value

Value to be assigned.

Details

encoding() uses l10n_info() and localeToCharset() (in this order) to determine the session encoding. If localeToCharset() returns NA, "UTF-8" is assumed to be the session encoding.

Value

A length-one character vector with an encoding.

Examples

# Get session charset.
encoding()

# Get encoding of a corpus.
encoding("REUTERS")

# Get encoding of a partition.
r <- partition("REUTERS", places = "kuwait", regex = TRUE)
encoding(r)

# Get encoding of another class inheriting from textstat (count).
cnt <- count("REUTERS", p_attribute = "word")
encoding(cnt)

# Get encoding of objects in a bundle.
pb <- partition_bundle("REUTERS", s_attribute = "id")
encoding(pb)

polmineR documentation built on Aug. 26, 2022, 5:15 p.m.