For a corpus object, returns the first or last n documents.

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

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

Arguments

x

a dfm object

n

a single integer. If positive, the number of documents 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.

...

additional arguments passed to other functions

Value

A corpus class object corresponding to the subset defined by n.

Examples

head(data_corpus_inaugural, 3) %>% summary()
#> Corpus consisting of 3 documents, showing 3 documents: #> #> Text Types Tokens Sentences Year President FirstName Party #> 1789-Washington 625 1537 23 1789 Washington George none #> 1793-Washington 96 147 4 1793 Washington George none #> 1797-Adams 826 2577 37 1797 Adams John Federalist #>
tail(data_corpus_inaugural, 3) %>% summary()
#> Corpus consisting of 3 documents, showing 3 documents: #> #> Text Types Tokens Sentences Year President FirstName Party #> 2013-Obama 814 2317 88 2013 Obama Barack Democratic #> 2017-Trump 582 1660 88 2017 Trump Donald J. Republican #> 2021-Biden.txt 811 2766 216 2021 Biden Joseph R. Democratic #>