Learn R Programming

quanteda (version 4.1.0)

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

Description

For a dfm object, return the dfm with only the first or last n documents.

Usage

# S3 method for dfm
head(x, n = 6L, ...)

# S3 method for dfm tail(x, n = 6L, ...)

Value

A dfm class object corresponding to the subset of documents determined by by n.

Arguments

x

a dfm object

n

an integer vector of length up to dim(x) (or 1, for non-dimensioned objects). A logical is silently coerced to integer. Values specify the indices to be selected in the corresponding dimension (or along the length) of the object. A positive value of n[i] includes the first/last n[i] indices in that dimension, while a negative value excludes the last/first abs(n[i]), including all remaining indices. NA or non-specified values (when length(n) < length(dim(x))) select all indices in that dimension. Must contain at least one non-missing value.

...

arguments to be passed to or from other methods.

Examples

Run this code
head(data_dfm_lbgexample, 3)
head(data_dfm_lbgexample, -4)

tail(data_dfm_lbgexample)
tail(data_dfm_lbgexample, n = 3)

Run the code above in your browser using DataLab