For a dfm object, returns the first or last `n`

documents
and first `nfeat`

features.

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

## Arguments

x |
a dfm object |

n |
a single, positive 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. |

nfeat |
the number of features to return, where the resulting object
will contain the first `ncol` features; default is all features |

... |
additional arguments passed to other functions |

## Value

A dfm class object corresponding to the subset defined
by `n`

and `nfeat`

.

## Examples

head(data_dfm_lbgexample, 3, nfeat = 5)

#> Document-feature matrix of: 3 documents, 5 features (66.7% sparse).
#> 3 x 5 sparse Matrix of class "dfm"
#> features
#> docs A B C D E
#> R1 2 3 10 22 45
#> R2 0 0 0 0 0
#> R3 0 0 0 0 0

head(data_dfm_lbgexample, -4)

#> Document-feature matrix of: 2 documents, 37 features (54.1% sparse).

tail(data_dfm_lbgexample)

#> Document-feature matrix of: 6 documents, 37 features (54.1% sparse).

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

#> Document-feature matrix of: 3 documents, 4 features (66.7% sparse).
#> 3 x 4 sparse Matrix of class "dfm"
#> features
#> docs ZH ZI ZJ ZK
#> R4 0 0 0 0
#> R5 22 10 3 2
#> V1 0 0 0 0