For a dfm object, return the dfm with only the first or last n
documents.
# S3 method for dfm head(x, n = 6L, ...) # S3 method for dfm tail(x, n = 6L, ...)
x | a dfm object |
---|---|
n | an integer vector of length up to |
... | arguments to be passed to or from other methods. |
A dfm class object corresponding to the subset of documents
determined by by n
.
head(data_dfm_lbgexample, 3) #> Document-feature matrix of: 3 documents, 37 features (54.05% sparse) and 0 docvars. #> features #> docs A B C D E F G H I J #> R1 2 3 10 22 45 78 115 146 158 146 #> R2 0 0 0 0 0 2 3 10 22 45 #> R3 0 0 0 0 0 0 0 0 0 0 #> [ reached max_nfeat ... 27 more features ] head(data_dfm_lbgexample, -4) #> Document-feature matrix of: 2 documents, 37 features (54.05% sparse) and 0 docvars. #> features #> docs A B C D E F G H I J #> R1 2 3 10 22 45 78 115 146 158 146 #> R2 0 0 0 0 0 2 3 10 22 45 #> [ reached max_nfeat ... 27 more features ] tail(data_dfm_lbgexample) #> Document-feature matrix of: 6 documents, 37 features (54.05% sparse) and 0 docvars. #> features #> docs A B C D E F G H I J #> R1 2 3 10 22 45 78 115 146 158 146 #> R2 0 0 0 0 0 2 3 10 22 45 #> R3 0 0 0 0 0 0 0 0 0 0 #> R4 0 0 0 0 0 0 0 0 0 0 #> R5 0 0 0 0 0 0 0 0 0 0 #> V1 0 0 0 0 0 0 0 2 3 10 #> [ reached max_nfeat ... 27 more features ] tail(data_dfm_lbgexample, n = 3) #> Document-feature matrix of: 3 documents, 37 features (54.05% sparse) and 0 docvars. #> features #> docs A B C D E F G H I J #> R4 0 0 0 0 0 0 0 0 0 0 #> R5 0 0 0 0 0 0 0 0 0 0 #> V1 0 0 0 0 0 0 0 2 3 10 #> [ reached max_nfeat ... 27 more features ]