R: Internal functions to set dimnames

set_dfm_dimnames<- {quanteda} | R Documentation

## 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

    dfmat <- dfm(tokens(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])

[Package quanteda version 3.1.0 Index]