set_dfm_dimnames: Internal functions to set dimnames

Description Usage Arguments Examples

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

1
2
3
4
5
6
7
8
9
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

1
2
3
4
dfmat <- dfm(c("a a b b c", "b b b c"))
quanteda.core:::set_dfm_featnames(dfmat) <- paste0("feature", 1:3)
quanteda.core:::set_dfm_docnames(dfmat) <- paste0("DOC", 1:2)
quanteda.core:::set_dfm_dimnames(dfmat) <- list(c("docA", "docB"), LETTERS[1:3])

koheiw/quanteda.core documentation built on Sept. 21, 2020, 3:44 p.m.