Learn R Programming

quanteda (version 2.0.1)

set_dfm_dimnames<-: Internal functions to set dimnames

Description

Default dimnames() converts a zero-length character vector to NULL, leading to the improper functioning of subsetting functions. These are safer methods to set the dimnames of a dfm or fcm object.

Usage

set_dfm_dimnames(x) <- value

set_dfm_docnames(x) <- value

set_dfm_featnames(x) <- value

set_fcm_dimnames(x) <- value

set_fcm_featnames(x) <- value

Arguments

x

dfm or fcm

value

character a vector for docnames or featnames or a list of them for dimnames

Examples

Run this code
# NOT RUN {
dfmat <- dfm(c("a a b b c", "b b b c"))
quanteda:::set_dfm_featnames(dfmat) <- paste0("feature", 1:3)
quanteda:::set_dfm_docnames(dfmat) <- paste0("DOC", 1:2)
quanteda:::set_dfm_dimnames(dfmat) <- list(c("docA", "docB"), LETTERS[1:3])
# }

Run the code above in your browser using DataLab