docnames: Get or set document names

Description Usage Arguments Value See Also Examples

Description

Get or set the document names of a corpus, tokens, or dfm object.

Usage

1
2
3
docnames(x)

docnames(x) <- value

Arguments

x

the object with docnames

value

a character vector of the same length as x

Value

docnames returns a character vector of the document names

docnames <- assigns new values to the document names of an object. docnames can only be character, so any non-character value assigned to be a docname will be coerced to mode 'character'.

See Also

featnames

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# get and set doument names to a corpus
corp <- data_corpus_inaugural
docnames(corp) <- char_tolower(docnames(corp))

# get and set doument names to a tokens
toks <- tokens(data_corpus_inaugural)
docnames(toks) <- char_tolower(docnames(toks))

# get and set doument names to a dfm
dfmat <- dfm(data_corpus_inaugural[1:5])
docnames(dfmat) <- char_tolower(docnames(dfmat))

# reassign the document names of the inaugural speech corpus
docnames(data_corpus_inaugural) <- paste("Speech", 1:ndoc(data_corpus_inaugural), sep="")

quanteda/quanteda documentation built on June 26, 2019, 3:38 a.m.