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.
encoding(object)
encoding(object) <- value
# S4 method for class 'missing'
encoding(object)
# S4 method for class 'textstat'
encoding(object)
# S4 method for class 'bundle'
encoding(object)
# S4 method for class 'character'
encoding(object)
# S4 method for class 'corpus'
encoding(object)
# S4 method for class 'subcorpus'
encoding(object)
# S4 method for class 'call'
encoding(object)
# S4 method for class 'quosure'
encoding(object)
# S4 method for class 'call'
encoding(object) <- value
# S4 method for class 'quosure'
encoding(object) <- valueA length-one character vector with an encoding.
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.
# Get session charset.
encoding()
#> [1] "UTF-8"
# Get encoding of a corpus.
encoding("REUTERS")
#> [1] "latin1"
# Get encoding of a partition.
r <- partition("REUTERS", places = "kuwait", regex = TRUE)
#> ... get cpos and strucs
encoding(r)
#> [1] "latin1"
# Get encoding of another class inheriting from textstat (count).
cnt <- count("REUTERS", p_attribute = "word")
encoding(cnt)
#> [1] "latin1"
# Get encoding of objects in a bundle.
pb <- partition_bundle("REUTERS", s_attribute = "id")
#> ℹ s-attribute "id" has values: yes
#> ℹ get regions and get values
#> ✔ get regions and get values [6ms]
#>
#> ℹ instantiate objects (n = 20)
#> ✔ instantiate objects (n = 20) [10ms]
#>
#> ℹ assign names
#> ✔ assign names [6ms]
#>
encoding(pb)
#> [1] "latin1"