Learn R Programming

quanteda (version 0.9.2-0)

head.dfm: Return the first or last part of a dfm

Description

For a dfm-class object, returns the first or last n documents and first ncol features for inspection.

Usage

## S3 method for class 'dfm':
head(x, n = 6L, nfeature = 6L, ...)

## S3 method for class 'dfm': head(x, n = 6L, nfeature = 6L, ...)

## S3 method for class 'dfm': tail(x, n = 6L, nfeature = 6L, ...)

## S3 method for class 'dfm': tail(x, n = 6L, nfeature = 6L, ...)

Arguments

x
a dfm object
n
a single integer. If positive, size for the resulting object: number of first/last documents for the dfm. If negative, all but the n last/first number of documents of x.
nfeature
the number of features to return, where the resulting object will contain the first ncol features
...
unused

Value

  • A dfm-class class object corresponding to the subset defined by n and ncol.

Examples

Run this code
myDfm <- dfm(inaugCorpus, ngrams = 2, verbose = FALSE)
head(myDfm)
tail(myDfm)
tail(myDfm, nfeature = 4)

Run the code above in your browser using DataLab