Learn R Programming

quanteda (version 0.9.2-0)

docvars: get or set for document-level variables

Description

Get or set variables for the documents in a corpus

Usage

docvars(x, field = NULL)

## S3 method for class 'corpus': docvars(x, field = NULL)

docvars(x, field = NULL) <- value

docvars(x, field = NULL) <- value

## S3 method for class 'corpusSource': docvars(x, field = NULL)

Arguments

x
corpus whose document-level variables will be read or set
field
string containing the document-level variable name
value
the new values of the document-level variable

Value

  • docvars returns a data.frame of the document-level variables

    docvars<- assigns value to the named field

Examples

Run this code
head(docvars(inaugCorpus))
docvars(inaugCorpus, "President") <- paste("prez", 1:ndoc(inaugCorpus), sep="")
head(docvars(inaugCorpus))

Run the code above in your browser using DataLab